Skip to content

Functions that exhaust iterators should take them by value. #13038

Closed
@Kimundi

Description

@Kimundi

Functions that exhaust iterators should take them by value, even if they don't require ownership.

Example:

   foo.extend(&mut bar.move_iter());
-> foo.extend(bar.move_iter());

This optimizes the ergonomy of using them for the common case where you don't need access to the iterator anymore after it is empty, while still retaining the ability to do so with the by_ref() adapter:

let mut iter = bar.move_iter();
foo.extend(iter.by_ref());
iter.baz();

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