-
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
Suggest Option::ok_or{,_else} #5923
Comments
Taking a stab at this one. I'm thinking of naming it match None {
Some(i) => i,
None => 1,
}; has a conciser alternative in: Let me know if that's a bad idea and you'd prefer one separate lint for every case. Alternative naming scheme would be a series like:
|
The problem with the name is, that it describes the code after the lint is applied. This means |
Correct, -er suffix only applies to one-syllable adjectives. In German, would have been fine no? 😅 The intent of |
I think it might make more sense to make a lint to capture cases where a method that exists in the standard library is being reimplemented, and then call it It is also worth pointing out that there already are several lints that handle cases of this (including |
Is there a mechanism in clippy to deprecate lint names and advertise new names? In that case, we could rename these lints into a common name if that is deemed worthwhile.
|
There are some lints which have been deprecated and whose deprecation notices say that they were replaced by a new lint ( That's a good point that we might want to extend it beyond just the specifics that |
I'm hesitant on combining lints from the |
I'll keep it to one name per case so the user can disable them independently. I'm going for |
You can open a PR about this, but expect some discussion on that PR, if lints should really get merged. I definitely think some lints can get merged, but wouldn't want to go through those lints myself. I'm happy to review your suggestion though! |
add lint manual_unwrap_or Implements partially #5923. changelog: add lint manual_unwrap_or
manual_unwrap_or / support Result::unwrap_or Implements partially #5923. changelog: support Result::unwrap_or in manual_unwrap_or
add manual_ok_or lint Implements partially #5923 changelog: add lint manual_ok_or
It was implemented so it can closed. Lint name is |
What it does
This lint should suggest calling
Option::ok_or
orOption::ok_or_else
when this functionality is reimplemented using theOption::map_or
orOption::map_or_else
functions, respectively.Categories (optional)
Makes it clearer that this is converting from an
Option
to aResult
, and produces shorter code.Drawbacks
None.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: