]> git.lizzy.rs Git - rust.git/blob - tests/ui/functions-closures/clone-closure.rs
Rollup merge of #107615 - notriddle:notriddle/nbsp, r=GuillaumeGomez
[rust.git] / tests / ui / functions-closures / clone-closure.rs
1 // run-pass
2 // Check that closures implement `Clone`.
3
4 #[derive(Clone)]
5 struct S(i32);
6
7 fn main() {
8     let mut a = S(5);
9     let mut hello = move || {
10         a.0 += 1;
11         println!("Hello {}", a.0);
12         a.0
13     };
14
15     let mut hello2 = hello.clone();
16     assert_eq!(6, hello2());
17     assert_eq!(6, hello());
18 }