Files
rust/tests/ui/closures/fnonce-call-twice-error.rs

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

17 lines
268 B
Rust
Raw Normal View History

2025-07-01 02:09:12 +05:00
//! Test that `FnOnce` closures cannot be called twice.
2013-06-17 19:25:06 -04:00
use std::sync::Arc;
2013-06-17 19:25:06 -04:00
2025-07-01 02:09:12 +05:00
fn foo<F: FnOnce()>(blk: F) {
2013-06-17 19:25:06 -04:00
blk();
blk(); //~ ERROR use of moved value
}
fn main() {
let x = Arc::new(true);
2025-07-01 02:09:12 +05:00
foo(move || {
assert!(*x);
drop(x);
2014-01-27 18:29:50 -05:00
});
2013-06-17 19:25:06 -04:00
}