From 602ce11299c339834636cab30c48c98cab0e43a3 Mon Sep 17 00:00:00 2001 From: LukeMathWalker <20745048+LukeMathWalker@users.noreply.github.com> Date: Mon, 13 May 2024 21:10:54 +0200 Subject: [PATCH] Complete section on read-only data segment. --- book/src/07_threads/02_static.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/book/src/07_threads/02_static.md b/book/src/07_threads/02_static.md index f209583..4c88289 100644 --- a/book/src/07_threads/02_static.md +++ b/book/src/07_threads/02_static.md @@ -104,9 +104,11 @@ The most common case is a reference to **static data**, such as string literals: let s: &'static str = "Hello world!"; ``` -Since string literals are known at compile-time, Rust's stores them in a memory -region known as ***. *** is part of the executable itself: there is no risk of it -being freed during program execution. +Since string literals are known at compile-time, Rust stores them *inside* your executable, +in a region known as **read-only data segment**. All references pointing to that region will therefore be valid for as long as the program runs; they satisfy the `'static` contract. +## Further reading + +- [The data segment](https://en.wikipedia.org/wiki/Data_segment) -- 2.45.2