Skip to content

Overcomplicated sample code for Option::iter_mut and Result::iter_mut #28431

Closed
@swatteau

Description

@swatteau

The code samples that illustrate the Option::iter_mut() and Result::iter_mut() use an overcomplicated pattern. For instance:

Some(&mut ref mut v) => *v = 42,

could be simplified to this:

Some(v) => *v = 42,

or, if we want to make it explicit that the value is a &mut T, to this:

Some(ref mut v) => **v = 42,

but then we need to dereference twice.

In any case, the current sample code seems to bring a lot of confusion for no good reason.

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