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:
Daniel Micay 2013-04-22 13:01:32 -04:00
parent d0451eebc4
commit c99409b332

View File

@ -20,7 +20,7 @@
*/
pub struct Cell<T> {
value: Option<T>
priv value: Option<T>
}
impl<T:cmp::Eq> cmp::Eq for Cell<T> {