I think ref pointer is strange in rust and if some one less newest than me can explain how it's deeply working.
fn functionc(var: &i32, opinion: &str) {
// {:p} print the address
println!("Ma value: address - {:p} & value - {:?} - {}", var, var, opinion);
}
fn main() {
let n = 55;
let i = 33;
let i2 = &i;
let i3 = &i2;
let i4 = &i3;
let i5 = &i4;
functionc(&n, "normal");
functionc(&i, "normal");
functionc(i2, "normal");
functionc(*i3, "normal"); // Good way
functionc(&i3, "strange"); // Hum shouldn't work
functionc(**i4, "normal");
functionc(***i5, "normal");
// functionc(****i5); Generate error: It's normal
functionc(&&&&&&&&&&&&&&&&&&&&&&&&&&&&i3, "strange"); // Hum OK why not ;)
}
I expected error on functionc(&i3, "strange");
But it works.
Who do magic:
let i3 = &i2;
or
functionc(&i3, "strange");
or
println!({:p});