summaryrefslogtreecommitdiffstats
path: root/src/test/ui/functions-closures/clone-closure.rs
blob: 1e725d8056d101ecf84f9b69987c758164dc95d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// run-pass
// Check that closures implement `Clone`.

#[derive(Clone)]
struct S(i32);

fn main() {
    let mut a = S(5);
    let mut hello = move || {
        a.0 += 1;
        println!("Hello {}", a.0);
        a.0
    };

    let mut hello2 = hello.clone();
    assert_eq!(6, hello2());
    assert_eq!(6, hello());
}