box-o-sand/rustbyexample/fn.d/closures.d/capture2.rs

9 lines
178 B
Rust
Raw Normal View History

2023-10-01 10:01:54 +00:00
fn main() {
let haystack = vec![1, 2, 3];
let contains = move |needle| haystack.contains(needle);
println!("{}", contains(&1));
println!("{}", contains(&4));
}