File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed
Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change 3333//! }
3434//! ```
3535//!
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
3737//! `'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`.
4441//!
4542//! # Representation
4643//!
4744//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as a
4845//! 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.
5148//!
5249//! The actual representation of strings have direct mappings to slices: `&str`
5350//! is the same as `&[u8]`.
You can’t perform that action at this time.
0 commit comments