mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
19 lines
239 B
Rust
19 lines
239 B
Rust
//@ run-pass
|
|
// Testing guarantees provided by once functions.
|
|
|
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
fn foo<F:FnOnce()>(blk: F) {
|
|
blk();
|
|
}
|
|
|
|
pub fn main() {
|
|
let x = Arc::new(true);
|
|
foo(move|| {
|
|
assert!(*x);
|
|
drop(x);
|
|
});
|
|
}
|