Closed huonw closed 8 years ago
&
UnsafeCell
the T type has no bounds, and so can be used to duplicate arbitrary data, e.g. this prints the same pointer twice:
T
fn main() { let x = VolatileCell::new(Box::new(1)); let y: Box<i32> = x.get(); let z: Box<i32> = x.get(); println!("{:p} {:p}", y, z); }
If this is trying to behave like std::cell::Cell, this could be fixed by bounding T: Copy.
std::cell::Cell
T: Copy
Fixed, thanks for pointing it out.
&
pointer unless that data is contained in anUnsafeCell
the
T
type has no bounds, and so can be used to duplicate arbitrary data, e.g. this prints the same pointer twice:If this is trying to behave like
std::cell::Cell
, this could be fixed by boundingT: Copy
.