Skip to content

10% of calls to .*iter() are redundant #26188

Closed
@Veedrac

Description

@Veedrac

The source has just over 200 calls to iter, iter_mut or into_iter to things that take and T: IntoIterator. This is, by my count, about 10% of them!

Some examples are left.extend(Some(x).into_iter()) instead of left.extend(Some(x)) and for &(s,t) in v.iter() instead of for &(s,t) in v.

I thought this would make a quick, trivial change to warm myself up to the build system and such, so I've already got a branch removing it. I thought I'd ask if it's actually desirable to do so, though, since it's a lot of seemingly-meaningless code churn.

If this is wanted, the docs should probably also be updated to emphasize that many calls to .*iter() aren't needed. Much of the documentation for iter() and co. uses them in places where they can be elided.

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