Hello,
Why when we move a variable in an other, these are not the same pointer ?
We can notice that the struct A
do not implement Copy
trait.
I don't understand this behavior because the data can not to be reach by the identifier (a
) anymore.
struct A();
impl fmt::Pointer for A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let ptr = self as *const Self;
fmt::Pointer::fmt(&ptr, f)
}
}
fn main() {
let a = A();
println!("a : {:p}",a);
let b = a;
println!("b : {:p}",b);
}
Output :
a : 0x7ffe05f10df8
b : 0x7ffe05f10e48