|
10 | 10 |
|
11 | 11 | //! Unicode string slices.
|
12 | 12 | //!
|
| 13 | +//! The `&str` type is one of the two main string types, the other being `String`. Unlike its `String` counterpart, its contents |
| 14 | +//! are borrowed and therefore cannot be moved someplace else. |
| 15 | +//! |
| 16 | +//! # Basic Usage |
| 17 | +//! A basic string declaration of `&str` type: |
| 18 | +//! |
| 19 | +//! ``` |
| 20 | +//! let hello_world = "Hello, World!"; |
| 21 | +//! ``` |
| 22 | +//! |
| 23 | +//! Here we have declared a string literal, also known as a string slice. |
| 24 | +//! String literals have a static lifetime, which means the string `hello_world` |
| 25 | +//! is guaranteed to be valid for the duration of the entire program. We can explicitly specify |
| 26 | +//! `hello_world`'s lifetime as well: |
| 27 | +//! |
| 28 | +//! ``` |
| 29 | +//! let hello_world:&'static str = "Hello, world!"; |
| 30 | +//! ``` |
| 31 | +//! |
13 | 32 | //! *[See also the `str` primitive type](../../std/primitive.str.html).*
|
14 | 33 |
|
15 |
| - |
16 | 34 | #![stable(feature = "rust1", since = "1.0.0")]
|
17 | 35 |
|
18 | 36 | // Many of the usings in this module are only used in the test configuration.
|
@@ -59,27 +77,6 @@ pub use std_unicode::str::SplitWhitespace;
|
59 | 77 | #[stable(feature = "rust1", since = "1.0.0")]
|
60 | 78 | pub use core::str::pattern;
|
61 | 79 |
|
62 |
| -/// Unicode string slices. |
63 |
| -/// |
64 |
| -/// The `&str` type is one of the two main string types, the other being `String`. Unlike its `String` counterpart, its contents |
65 |
| -/// are borrowed and therefore cannot be moved someplace else. |
66 |
| -/// |
67 |
| -/// # Basic Usage |
68 |
| -/// A basic string declaration of `&str` type: |
69 |
| -/// |
70 |
| -/// ``` |
71 |
| -/// let hello_world = "Hello, World!"; |
72 |
| -/// ``` |
73 |
| -/// Here we have declared a string literal, also known as a string slice. |
74 |
| -/// String literals have a static lifetime, which means the string `hello_world` |
75 |
| -/// is guaranteed to be valid for the duration of the entire program. We can explicitly specify |
76 |
| -/// `hello_world`'s lifetime as well: |
77 |
| -/// |
78 |
| -/// ``` |
79 |
| -/// let hello_world:&'static str = "Hello, world!"; |
80 |
| -/// ``` |
81 |
| -/// |
82 |
| -
|
83 | 80 | #[unstable(feature = "slice_concat_ext",
|
84 | 81 | reason = "trait should not have to exist",
|
85 | 82 | issue = "27747")]
|
|
0 commit comments