Skip to content

Deprecate while_some() in favor of map_while() #1120

Description

@ronnodas

The while_some() adapter is a simple special case map_while(|x| x). Historically it made sense to have such a method: while_some() was added to itertools 0.3 in 2015, while map_while() was stabilized in Rust 1.57 in 2021. Given the 5+ years and the current MSRV of 1.63, I think it makes sense to deprecate and eventually remove while_some().

Sampling a basic GitHub search:

  • Many uses seem to be .map().while_some(), which is equivalent to just a single map_while().
  • Similarly, repeat_with().while_some() can be from_fn().
  • Some of the uses are of rayon::ParallelIterator::while_some(), which doesn't have a map_while()

Of course the deprecation notice can just suggest map_while(identity) and let clippy et al deal with further simplifications.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions