mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
18 lines
309 B
Rust
18 lines
309 B
Rust
// Testing guarantees provided by once functions.
|
|
// This program would segfault if it were legal.
|
|
|
|
use std::sync::Arc;
|
|
|
|
fn foo<F:FnOnce()>(blk: F) {
|
|
blk();
|
|
blk(); //~ ERROR use of moved value
|
|
}
|
|
|
|
fn main() {
|
|
let x = Arc::new(true);
|
|
foo(move|| {
|
|
assert!(*x);
|
|
drop(x);
|
|
});
|
|
}
|