Skip to content

map_flatten: suggest just flatten where map(|a| a.into_iter()).flatten() #12241

Open

Description

Description

map_flatten could suggest flatten() on map(|a| a.into_iter()).flatten() instead of flat_map(|b| b.into_iter()).

Example:

use bytes::Bytes;

pub fn flatten_bytes_seq(bytes_collection: Vec<Bytes>) -> Bytes {
    bytes_collection.into_iter().map(|b| b.into_iter()).flatten().collect()
}

can be

use bytes::Bytes;

pub fn flatten_bytes_seq(bytes_collection: Vec<Bytes>) -> Bytes {
    bytes_collection.into_iter().flatten().collect()
}

version: 1.75.0 on playground

Version

No response

Additional Labels

@rustbot label +C-enhancement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions