|
8 | 8 | // option. This file may not be copied, modified, or distributed
|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 |
| -//! Unicode string manipulation (the `str` type). |
| 11 | +//! Unicode string slices |
12 | 12 | //!
|
13 |
| -//! Rust's `str` type is one of the core primitive types of the language. `&str` |
14 |
| -//! is the borrowed string type. This type of string can only be created from |
15 |
| -//! other strings, unless it is a `&'static str` (see below). It is not possible |
16 |
| -//! to move out of borrowed strings because they are owned elsewhere. |
17 |
| -//! |
18 |
| -//! # Examples |
19 |
| -//! |
20 |
| -//! Here's some code that uses a `&str`: |
21 |
| -//! |
22 |
| -//! ``` |
23 |
| -//! let s = "Hello, world."; |
24 |
| -//! ``` |
25 |
| -//! |
26 |
| -//! This `&str` is a `&'static str`, which is the type of string literals. |
27 |
| -//! They're `'static` because literals are available for the entire lifetime of |
28 |
| -//! the program. |
29 |
| -//! |
30 |
| -//! You can get a non-`'static` `&str` by taking a slice of a `String`: |
31 |
| -//! |
32 |
| -//! ``` |
33 |
| -//! let some_string = "Hello, world.".to_string(); |
34 |
| -//! let s = &some_string; |
35 |
| -//! ``` |
36 |
| -//! |
37 |
| -//! # Representation |
38 |
| -//! |
39 |
| -//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as |
40 |
| -//! a stream of UTF-8 bytes. All [strings](../../reference.html#literals) are |
41 |
| -//! guaranteed to be validly encoded UTF-8 sequences. Additionally, strings are |
42 |
| -//! not null-terminated and can thus contain null bytes. |
43 |
| -//! |
44 |
| -//! The actual representation of `str`s have direct mappings to slices: `&str` |
45 |
| -//! is the same as `&[u8]`. |
| 13 | +//! *[See also the `str` primitive type](../primitive.str.html).* |
| 14 | +
|
46 | 15 |
|
47 |
| -#![doc(primitive = "str")] |
48 | 16 | #![stable(feature = "rust1", since = "1.0.0")]
|
49 | 17 |
|
50 | 18 | // Many of the usings in this module are only used in the test configuration.
|
|
0 commit comments