rust/tests/run-pass/std.rs

35 lines
658 B
Rust
Raw Normal View History

use std::cell::Cell;
2016-04-06 05:20:35 -05:00
use std::rc::Rc;
use std::sync::Arc;
fn rc_cell() -> Rc<Cell<i32>> {
2016-03-21 05:18:30 -05:00
let r = Rc::new(Cell::new(42));
let x = r.get();
r.set(x + x);
2016-04-06 05:20:35 -05:00
r
2016-03-21 05:18:30 -05:00
}
2016-05-09 21:08:37 -05:00
// TODO(solson): also requires destructors to run for the second borrow to work
// TODO(solson): needs StructWrappedNullablePointer support
2016-03-21 19:53:39 -05:00
// fn rc_refcell() -> i32 {
// let r = Rc::new(RefCell::new(42));
// *r.borrow_mut() += 10;
// let x = *r.borrow();
// x
// }
2016-04-06 05:20:35 -05:00
fn arc() -> Arc<i32> {
2016-03-21 05:18:30 -05:00
let a = Arc::new(42);
2016-04-06 05:20:35 -05:00
a
}
2016-03-21 05:37:28 -05:00
fn true_assert() {
assert_eq!(1, 1);
}
2016-04-22 03:34:14 -05:00
2016-04-22 07:38:46 -05:00
fn main() {
assert_eq!(*arc(), 42);
assert_eq!(rc_cell().get(), 84);
true_assert();
2016-04-22 07:38:46 -05:00
}