#[test]
fn test_ptr() {
#[derive(Debug)]
struct Foo{
a:i32
}
impl Pointer for Foo {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let ptr = self as *const Self;
ptr.fmt(f)
}
}
let mut f1 = Foo{a:10};
unsafe {
let f2 = ptr::read(&f1);
println!("{:p}", f1);
println!("{:p}", f2);
}
}
为什么打印的两个指针不一样
1
共 1 条评论, 1 页
评论区
写评论这不是 copy 了一份么,怎么会一样