How shared and mutable references point at a value without owning it
The compiled program has been loaded into memory, but no function has run yet. Nothing is on the stack and nothing is on the heap
1fn main() {2 let mut s = String::from("hi");3 let r1 = &s;4 let r2 = &s;5 println!("{r1} {r2}");6 let m = &mut s;7 m.push('!');8}How shared and mutable references point at a value without owning it
&mut is really about exclusive access; Cell and RefCell allow changing data through a shared & referencer1 and r2 point at s on the stack, not at the heap buffer, so reading through them follows two pointersString from capacity 2 jumps straight to 8, because the standard library uses a minimum capacity of 8 for 1-byte elements$cargorun// waiting for the first println!