Complete section on read-only data segment.
This commit is contained in:
parent
04c4e55b37
commit
602ce11299
|
@ -104,9 +104,11 @@ The most common case is a reference to **static data**, such as string literals:
|
||||||
let s: &'static str = "Hello world!";
|
let s: &'static str = "Hello world!";
|
||||||
```
|
```
|
||||||
|
|
||||||
Since string literals are known at compile-time, Rust's stores them in a memory
|
Since string literals are known at compile-time, Rust stores them *inside* your executable,
|
||||||
region known as ***. *** is part of the executable itself: there is no risk of it
|
in a region known as **read-only data segment**.
|
||||||
being freed during program execution.
|
|
||||||
All references pointing to that region will therefore be valid for as long as
|
All references pointing to that region will therefore be valid for as long as
|
||||||
the program runs; they satisfy the `'static` contract.
|
the program runs; they satisfy the `'static` contract.
|
||||||
|
|
||||||
|
## Further reading
|
||||||
|
|
||||||
|
- [The data segment](https://en.wikipedia.org/wiki/Data_segment)
|
||||||
|
|
Loading…
Reference in New Issue