We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a98e7ab + 515ed80 commit fb94992Copy full SHA for fb94992
clippy_lints/src/methods/mod.rs
@@ -566,17 +566,20 @@ declare_clippy_lint! {
566
///
567
/// ### Why is this bad?
568
/// Readability, this can be written more concisely as
569
- /// `_.flat_map(_)`
+ /// `_.flat_map(_)` for `Iterator` or `_.and_then(_)` for `Option`
570
571
/// ### Example
572
/// ```rust
573
/// let vec = vec![vec![1]];
574
+ /// let opt = Some(5);
575
576
/// // Bad
577
/// vec.iter().map(|x| x.iter()).flatten();
578
+ /// opt.map(|x| Some(x * 2)).flatten();
579
580
/// // Good
581
/// vec.iter().flat_map(|x| x.iter());
582
+ /// opt.and_then(|x| Some(x * 2));
583
/// ```
584
#[clippy::version = "1.31.0"]
585
pub MAP_FLATTEN,
0 commit comments