1 #![feature(custom_attribute, box_syntax)]
2 #![allow(dead_code, unused_attributes)]
4 use std::cell::{Cell, RefCell};
9 fn rc_cell() -> Rc<Cell<i32>> {
10 let r = Rc::new(Cell::new(42));
16 // TODO(tsion): borrow code needs to evaluate string statics via Lvalue::Static
17 // TODO(tsion): also requires destructors to run for the second borrow to work
19 // fn rc_refcell() -> i32 {
20 // let r = Rc::new(RefCell::new(42));
21 // *r.borrow_mut() += 10;
22 // let x = *r.borrow();
27 fn arc() -> Arc<i32> {
32 struct Loop(Rc<RefCell<Option<Loop>>>);
35 fn rc_reference_cycle() -> Loop {
36 let a = Rc::new(RefCell::new(None));
38 *a.borrow_mut() = Some(Loop(b));
49 //let x = rc_reference_cycle().0;
50 //assert!(x.borrow().is_some());
51 assert_eq!(*arc(), 42);
52 assert_eq!(rc_cell().get(), 84);