-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Lint Suggestion: reimplementing .and_then with Some(x?) #6410
Comments
Nice. This can include any case of |
If no one has attempted this yet, I'd like to give it a shot. |
Ok, so let me see if I've understood this correctly. What needs to be recognized; How can it be matched: What help can be suggested: Have I overseen anything? |
You have to worry about the early exit of |
TODO: The suggestion message still contains the ? Issue rust-lang#6410
TODO: The suggestion message still contains the ? Issue rust-lang#6410
Ok, I think I've got it done. I'll go open a PR. |
Needless Question Mark Lint Fixes #6410, i.e the needless question mark lint
What it does
Suggest
option.and_then(|value| value.inner_option)
instead ofoption.and_then(|value| Some(value.inner_option?))
Categories (optional)
What is the advantage of the recommended code over the original code
There's no reason to take an option, wrap it in another option, and use ? to short-circuit.
and_then
will work fine without it, and it's needlessly difficult to read.Drawbacks
None.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: