rust/tests/ui/closures/once-move-out-on-heap.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
239 B
Rust
Raw Normal View History

//@ run-pass
2013-06-17 23:25:06 +00:00
// Testing guarantees provided by once functions.
2013-06-29 07:54:09 +00:00
use std::sync::Arc;
2013-06-17 23:25:06 +00:00
fn foo<F:FnOnce()>(blk: F) {
2013-06-17 23:25:06 +00:00
blk();
}
pub fn main() {
let x = Arc::new(true);
foo(move|| {
assert!(*x);
drop(x);
2014-01-27 23:29:50 +00:00
});
2013-06-17 23:25:06 +00:00
}