Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
swatteau opened this issue Sep 16, 2015 · 0 comments
Closed

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

swatteau opened this issue Sep 16, 2015 · 0 comments

Comments

@swatteau
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants