mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
19 lines
321 B
Rust
19 lines
321 B
Rust
//@ 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());
|
|
}
|