trpl-zh-cn/listings/ch13-functional-features/no-listing-03-move-closures/src/main.rs

12 lines
181 B
Rust
Raw Normal View History

2022-02-06 16:43:51 +08:00
fn main() {
let x = vec![1, 2, 3];
let equal_to_x = move |z| z == x;
println!("can't use x here: {:?}", x);
let y = vec![1, 2, 3];
assert!(equal_to_x(y));
}