File tree 1 file changed +7
-8
lines changed
1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -298,26 +298,25 @@ declare_clippy_lint! {
298
298
/// **What it does:** Checks `for` loops over slices with an explicit counter
299
299
/// and suggests the use of `.enumerate()`.
300
300
///
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.
304
303
///
305
304
/// **Known problems:** None.
306
305
///
307
306
/// **Example:**
308
307
/// ```rust
309
308
/// # let v = vec![1];
310
- /// # fn foo(bar: usize) {}
311
309
/// # 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
+ /// }
314
315
/// ```
315
316
/// Could be written as
316
317
/// ```rust
317
318
/// # let v = vec![1];
318
- /// # fn foo(bar: usize) {}
319
319
/// # fn bar(bar: usize, baz: usize) {}
320
- /// for item in &v { foo(*item); }
321
320
/// for (i, item) in v.iter().enumerate() { bar(i, *item); }
322
321
/// ```
323
322
pub EXPLICIT_COUNTER_LOOP ,
You can’t perform that action at this time.
0 commit comments