File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -298,26 +298,25 @@ declare_clippy_lint! {
298298 /// **What it does:** Checks `for` loops over slices with an explicit counter
299299 /// and suggests the use of `.enumerate()`.
300300 ///
301- /// **Why is it bad?** Not only is the version using `.enumerate()` more
302- /// readable, the compiler is able to remove bounds checks which can lead to
303- /// faster code in some instances.
301+ /// **Why is it bad?** Using `.enumerate()` makes the intent more clear,
302+ /// declutters the code and may be faster in some instances.
304303 ///
305304 /// **Known problems:** None.
306305 ///
307306 /// **Example:**
308307 /// ```rust
309308 /// # let v = vec![1];
310- /// # fn foo(bar: usize) {}
311309 /// # fn bar(bar: usize, baz: usize) {}
312- /// for i in 0..v.len() { foo(v[i]); }
313- /// for i in 0..v.len() { bar(i, v[i]); }
310+ /// let mut i = 0;
311+ /// for item in &v {
312+ /// bar(i, *item);
313+ /// i += 1;
314+ /// }
314315 /// ```
315316 /// Could be written as
316317 /// ```rust
317318 /// # let v = vec![1];
318- /// # fn foo(bar: usize) {}
319319 /// # fn bar(bar: usize, baz: usize) {}
320- /// for item in &v { foo(*item); }
321320 /// for (i, item) in v.iter().enumerate() { bar(i, *item); }
322321 /// ```
323322 pub EXPLICIT_COUNTER_LOOP ,
You can’t perform that action at this time.
0 commit comments