Skip to content

Commit 5e7b873

Browse files
committed
Add known issue to docs and simplify
We make the docs talk about repeat, rather than repeat_with. This is because they are basically the same, but repeat is slightly more obvious
1 parent 42f7309 commit 5e7b873

File tree

1 file changed

+10
-2
lines changed
  • clippy_lints/src/methods

1 file changed

+10
-2
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4132,7 +4132,7 @@ declare_clippy_lint! {
41324132
/// ### What it does
41334133
///
41344134
/// Checks for `Iterator::map` over ranges without using the parameter which
4135-
/// could be more clearly expressed using `std::iter::repeat_with(...).take(...)`.
4135+
/// could be more clearly expressed using `std::iter::repeat(...).take(...)`.
41364136
///
41374137
/// ### Why is this bad?
41384138
///
@@ -4141,13 +4141,21 @@ declare_clippy_lint! {
41414141
/// range only to discard them.
41424142
///
41434143
/// ### Example
4144+
///
41444145
/// ```no_run
41454146
/// let random_numbers : Vec<_> = (0..10).map(|_| { 3 + 1 }).collect();
41464147
/// ```
41474148
/// Use instead:
41484149
/// ```no_run
4149-
/// let f : Vec<_> = std::iter::repeat_with(|| { 3 + 1 }).take(10).collect();
4150+
/// let f : Vec<_> = std::iter::repeat( 3 + 1 ).take(10).collect();
41504151
/// ```
4152+
///
4153+
/// ### Known Issues
4154+
///
4155+
/// This lint suggest replacing a `Map<Range>` with a `Take<RepeatWith>` or
4156+
/// `Take<Repeat>`. The former implements some traits that the latter two do
4157+
/// not, such as `DoubleEndedIterator`. As a result, this may not always be an
4158+
/// appropriate suggestion.
41514159
#[clippy::version = "1.81.0"]
41524160
pub MAP_WITH_UNUSED_ARGUMENT_OVER_RANGES,
41534161
style,

0 commit comments

Comments
 (0)