We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 321dc45 + 8e15148 commit 6f99c15Copy full SHA for 6f99c15
1 file changed
src/fn/closures/closure_examples/iter_find.md
@@ -42,9 +42,12 @@ fn main() {
42
let array1 = [1, 2, 3];
43
let array2 = [4, 5, 6];
44
45
- // `array1.iter()` yields `&i32`
+ // `array1.iter()` yields `&i32`, and `find` passes `&Item` to the
46
+ // predicate. Since `Item = &i32`, the closure argument has type `&&i32`.
47
println!("Find 2 in array1: {:?}", array1.iter().find(|&&x| x == 2));
- // `array2.into_iter()` yields `i32`
48
+ // `array2.into_iter()` yields `i32` (since Rust 2021 edition), and
49
+ // `find` passes `&Item` to the predicate. Since `Item = i32`, the
50
+ // closure argument has type `&i32`.
51
println!("Find 2 in array2: {:?}", array2.into_iter().find(|&x| x == 2));
52
}
53
```
0 commit comments