mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
auto merge of #18456 : gamazeps/rust/issue18449, r=thestinger
Made the fact that rodata is a section of the executable more explicit Closes #18449
This commit is contained in:
commit
b87619e274
@ -33,21 +33,18 @@
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! From the example above, you can see that Rust's string literals have the
|
||||
//! From the example above, you can guess that Rust's string literals have the
|
||||
//! `'static` lifetime. This is akin to C's concept of a static string.
|
||||
//!
|
||||
//! String literals are allocated statically in the rodata of the
|
||||
//! executable/library. The string then has the type `&'static str` meaning that
|
||||
//! the string is valid for the `'static` lifetime, otherwise known as the
|
||||
//! lifetime of the entire program. As can be inferred from the type, these static
|
||||
//! strings are not mutable.
|
||||
//! More precisely, string literals are immutable views with a 'static lifetime
|
||||
//! (otherwise known as the lifetime of the entire program), and thus have the
|
||||
//! type `&'static str`.
|
||||
//!
|
||||
//! # Representation
|
||||
//!
|
||||
//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as a
|
||||
//! stream of UTF-8 bytes. All strings are guaranteed to be validly encoded UTF-8
|
||||
//! sequences. Additionally, strings are not null-terminated and can contain null
|
||||
//! bytes.
|
||||
//! sequences. Additionally, strings are not null-terminated and can thus contain
|
||||
//! null bytes.
|
||||
//!
|
||||
//! The actual representation of strings have direct mappings to slices: `&str`
|
||||
//! is the same as `&[u8]`.
|
||||
|
Loading…
Reference in New Issue
Block a user