2018-10-17 08:15:53 -05:00
|
|
|
use std::cell::RefCell;
|
|
|
|
|
2019-04-17 01:35:06 -05:00
|
|
|
fn main() {
|
2018-10-17 08:15:53 -05:00
|
|
|
let c = RefCell::new(42);
|
|
|
|
{
|
|
|
|
let s1 = c.borrow();
|
|
|
|
let _x: i32 = *s1;
|
|
|
|
let s2 = c.borrow();
|
|
|
|
let _x: i32 = *s1;
|
|
|
|
let _y: i32 = *s2;
|
|
|
|
let _x: i32 = *s1;
|
|
|
|
let _y: i32 = *s2;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
let mut m = c.borrow_mut();
|
|
|
|
let _z: i32 = *m;
|
|
|
|
{
|
|
|
|
let s: &i32 = &*m;
|
|
|
|
let _x = *s;
|
|
|
|
}
|
|
|
|
*m = 23;
|
|
|
|
let _z: i32 = *m;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
let s1 = c.borrow();
|
|
|
|
let _x: i32 = *s1;
|
|
|
|
let s2 = c.borrow();
|
|
|
|
let _x: i32 = *s1;
|
|
|
|
let _y: i32 = *s2;
|
|
|
|
let _x: i32 = *s1;
|
|
|
|
let _y: i32 = *s2;
|
|
|
|
}
|
|
|
|
}
|