fn main() {
let c: i32 = 5;
let rrc = &&c;
println!("{}", rrc); // 5
println!("{}", *rrc); // 5
println!("{}", **rrc); // 5
}
In C/C++ language, rrc likes a two level pointer. In this example, rrc doesn't mean this in rust. What do & and * mean in Rust?
The reason they all print the same thing is that borrows (
&T) in Rust implementsDisplayforT: Displayby dispatching it to the pointed type. If you want to print the actual pointer value, you have to use{:p}.See the playground.