Skip to content

Commit de3d587

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 5271580 commit de3d587

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
@@ -4131,7 +4131,7 @@ declare_clippy_lint! {
41314131
/// ### What it does
41324132
///
41334133
/// Checks for `Iterator::map` over ranges without using the parameter which
4134-
/// could be more clearly expressed using `std::iter::repeat_with(...).take(...)`.
4134+
/// could be more clearly expressed using `std::iter::repeat(...).take(...)`.
41354135
///
41364136
/// ### Why is this bad?
41374137
///
@@ -4140,13 +4140,21 @@ declare_clippy_lint! {
41404140
/// range only to discard them.
41414141
///
41424142
/// ### Example
4143+
///
41434144
/// ```no_run
41444145
/// let random_numbers : Vec<_> = (0..10).map(|_| { 3 + 1 }).collect();
41454146
/// ```
41464147
/// Use instead:
41474148
/// ```no_run
4148-
/// let f : Vec<_> = std::iter::repeat_with(|| { 3 + 1 }).take(10).collect();
4149+
/// let f : Vec<_> = std::iter::repeat( 3 + 1 ).take(10).collect();
41494150
/// ```
4151+
///
4152+
/// ### Known Issues
4153+
///
4154+
/// This lint suggest replacing a `Map<Range>` with a `Take<RepeatWith>` or
4155+
/// `Take<Repeat>`. The former implements some traits that the latter two do
4156+
/// not, such as `DoubleEndedIterator`. As a result, this may not always be an
4157+
/// appropriate suggestion.
41504158
#[clippy::version = "1.81.0"]
41514159
pub MAP_WITH_UNUSED_ARGUMENT_OVER_RANGES,
41524160
style,

0 commit comments

Comments
 (0)