Skip to content

allow rvalue temporaries to be borrowed as &mut #5967

Closed
@thestinger

Description

@thestinger

You can currently borrow an rvalue as & or move out of it, but can't borrow it as &mut.

The use case for this is making external iterators more convenient to use by not requiring a temporary. Instead of let mut it = x.chain(y).zip(z); for it.advance |x| { ... } it could just be for x.chain(y).zip(z).advance |x| { ... }.

I've run into this in a few other places but I didn't think twice about it and just did the temporary workaround - but after some thought this seems like an unnecessary restriction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions