2 #![feature(custom_attribute, box_syntax)]
3 #![allow(dead_code, unused_attributes)]
5 use std::cell::{Cell, RefCell};
10 fn rc_cell() -> Rc<Cell<i32>> {
11 let r = Rc::new(Cell::new(42));
17 // TODO(tsion): borrow code needs to evaluate string statics via Lvalue::Static
18 // TODO(tsion): also requires destructors to run for the second borrow to work
20 // fn rc_refcell() -> i32 {
21 // let r = Rc::new(RefCell::new(42));
22 // *r.borrow_mut() += 10;
23 // let x = *r.borrow();
28 fn arc() -> Arc<i32> {
33 struct Loop(Rc<RefCell<Option<Loop>>>);
36 fn rc_reference_cycle() -> Loop {
37 let a = Rc::new(RefCell::new(None));
39 *a.borrow_mut() = Some(Loop(b));