From 8e1514804f609591d824af7098198f6bac2909d0 Mon Sep 17 00:00:00 2001 From: streamatron/ragebaiter Date: Tue, 31 Mar 2026 18:40:31 -0700 Subject: [PATCH] fix: correct iter/into_iter type comments in iter_find example (#1982) --- src/fn/closures/closure_examples/iter_find.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/fn/closures/closure_examples/iter_find.md b/src/fn/closures/closure_examples/iter_find.md index cbcc1ac542..368ed1356c 100644 --- a/src/fn/closures/closure_examples/iter_find.md +++ b/src/fn/closures/closure_examples/iter_find.md @@ -42,9 +42,12 @@ fn main() { let array1 = [1, 2, 3]; let array2 = [4, 5, 6]; - // `array1.iter()` yields `&i32` + // `array1.iter()` yields `&i32`, and `find` passes `&Item` to the + // predicate. Since `Item = &i32`, the closure argument has type `&&i32`. println!("Find 2 in array1: {:?}", array1.iter().find(|&&x| x == 2)); - // `array2.into_iter()` yields `i32` + // `array2.into_iter()` yields `i32` (since Rust 2021 edition), and + // `find` passes `&Item` to the predicate. Since `Item = i32`, the + // closure argument has type `&i32`. println!("Find 2 in array2: {:?}", array2.into_iter().find(|&x| x == 2)); } ```