Consider this example:
#![feature(shared, unique)]
use std::ptr::{Shared, Unique};
use std::rc::Rc;
use std::sync::Arc;
fn main() {
let x = Box::new(10);
assert_eq!(format!("{:p}", &*x), format!("{:p}", x));
let a = &mut 10 as *mut _;
let x = Shared::new(a).unwrap();
assert_eq!(format!("{:p}", a), format!("{:p}", x));
let a = &mut 10 as *mut _;
let x = Unique::new(a).unwrap();
assert_eq!(format!("{:p}", a), format!("{:p}", x));
let x = Rc::new(10);
println!("rc {:p} {:p}", &*x, x);
let x = Arc::new(10);
println!("arc {:p} {:p}", &*x, x);
}
the code runs fine but the printed values are different:
rc 0x7f1eefa1e070 0x7f1eefa1e060
arc 0x7f1eefa1e0d0 0x7f1eefa1e0c0
The Pointer implementation for Rc and Arc prints the address of the inner data (RcBox and ArcInner) instead of the address of the stored value. This seems to be inconsistent with the Pointer implementation for Box, Shared and Unique.
If this is a real issue, I can write a patch to fix it.
Consider this example:
the code runs fine but the printed values are different:
The
Pointerimplementation forRcandArcprints the address of the inner data (RcBoxandArcInner) instead of the address of the stored value. This seems to be inconsistent with thePointerimplementation forBox,SharedandUnique.If this is a real issue, I can write a patch to fix it.