cell: public field is unsafe
use core::cell; fn main() { let x = cell::Cell(Some(~"foo")); let y = x.value.get_ref().get_ref(); do x.with_mut_ref |z| { *z = None; } println(*y) // boom! }
This commit is contained in:
parent
d0451eebc4
commit
c99409b332
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
pub struct Cell<T> {
|
||||
value: Option<T>
|
||||
priv value: Option<T>
|
||||
}
|
||||
|
||||
impl<T:cmp::Eq> cmp::Eq for Cell<T> {
|
||||
|
Loading…
Reference in New Issue
Block a user