about summary refs log tree commit diff
path: root/tests/ui/functions-closures/copy-closure.rs
blob: 313d39eac3d62ea2d6f6620755b4dbd329b45d60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//@ run-pass
// 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));
}