rust/tests/ui/functions-closures/copy-closure.rs

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

17 lines
308 B
Rust
Raw Normal View History

// run-pass
2017-09-13 20:40:48 +00:00
// Check that closures implement `Copy`.
fn call<T, F: FnOnce() -> T>(f: F) -> T { f() }
fn main() {
let a = 5;
let hello = || {
println!("Hello {}", a);
a
};
assert_eq!(5, call(hello.clone()));
assert_eq!(5, call(hello));
assert_eq!(5, call(hello));
}