mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 10:18:25 +00:00
17 lines
268 B
Rust
17 lines
268 B
Rust
//! Test that `FnOnce` closures cannot be called twice.
|
|
|
|
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);
|
|
});
|
|
}
|