File tree 1 file changed +6
-9
lines changed
1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change 33
33
//! }
34
34
//! ```
35
35
//!
36
- //! From the example above, you can see that Rust's string literals have the
36
+ //! From the example above, you can guess that Rust's string literals have the
37
37
//! `'static` lifetime. This is akin to C's concept of a static string.
38
- //!
39
- //! String literals are allocated statically in the rodata of the
40
- //! executable/library. The string then has the type `&'static str` meaning that
41
- //! the string is valid for the `'static` lifetime, otherwise known as the
42
- //! lifetime of the entire program. As can be inferred from the type, these static
43
- //! strings are not mutable.
38
+ //! More precisely, string literals are immutable views with a 'static lifetime
39
+ //! (otherwise known as the lifetime of the entire program), and thus have the
40
+ //! type `&'static str`.
44
41
//!
45
42
//! # Representation
46
43
//!
47
44
//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as a
48
45
//! stream of UTF-8 bytes. All strings are guaranteed to be validly encoded UTF-8
49
- //! sequences. Additionally, strings are not null-terminated and can contain null
50
- //! bytes.
46
+ //! sequences. Additionally, strings are not null-terminated and can thus contain
47
+ //! null bytes.
51
48
//!
52
49
//! The actual representation of strings have direct mappings to slices: `&str`
53
50
//! is the same as `&[u8]`.
You can’t perform that action at this time.
0 commit comments