Section 4.3 about slices of The Rust Programming Language has this paragraph:
String Literals Are Slices
Recall that we talked about string literals being stored inside the binary. Now that we know about slices, we can properly understand string literals:
let s = "Hello, world!";
The type of
s
here is&str
: it’s a slice pointing to that specific point of the binary. This is also why string literals are immutable;&str
is an immutable reference.
Now, a string slice is, as they've covered earlier, a pair (of some sort) containing a pointer and a length. To me, this paragraph (specifically "we talked about string literals being stored inside the binary" and "pointing to that specific point of the binary") seems to imply that that pointer goes straight into program memory. Not the stack, not the heap, but the actual place where the processor stores all the instructions that the program consists of. A specific line of the assembly, if you will.
Is this true? If not, what else could they mean by that, and how is it actually done? How can I figure this out myself if I have a similar question later along the line?