Skip to content
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

result_map_unwrap_or_else: drop the .ok() in the suggestion #4728

Closed

Conversation

mathstuf
Copy link
Contributor

Adding the .ok() changes the semantics since that assumes that g was
ignoring its argument. Instead, allow g to keep taking its argument
and preserve the isomorphism to the original code in the suggestion.

Fixes #1590

Cc: @gendx @Arnavion


changelog: fix result_map_unwrap_or_else suggestion to preserve isomorphism

@Arnavion
Copy link
Contributor

(This should not be merged until Result::map_or_else is on the path to stabilization.)

Adding the `.ok()` changes the semantics since that assumes that `g` was
ignoring its argument. Instead, allow `g` to keep taking its argument
and preserve the isomorphism to the original code in the suggestion.

Fixes rust-lang#1590
@mathstuf mathstuf force-pushed the improve-result-map-unwrap_or_else branch from c273af2 to b546fd3 Compare October 25, 2019 12:38
@mathstuf
Copy link
Contributor Author

In the meantime, should the Known problems be updated to mention the caveat due to the .ok() suggestion?

@Arnavion
Copy link
Contributor

Sure, or fix it to only fire when g ignores its parameter, like I wrote in #1590 (comment)

@flip1995 flip1995 added the S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work label Oct 26, 2019
@flip1995 flip1995 added A-lint Area: New lints and removed A-lint Area: New lints labels Nov 25, 2019
@flip1995
Copy link
Member

Superseded by #4848

@flip1995 flip1995 closed this Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend option-map-unwrap-or-else to Result
3 participants