You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This lint would warn against using the Option type for local variables when the None value is unused.
Advantage
Remove the unnecessary Options makes the source code more readable and effective.
Drawbacks
To make the lint more effective and simple, the implementation of the lint should not be exhaustive. It makes sense to iterate over HIR and mark an Option variable as "used" if it is used as an argument of a function call, i.e. don't propagate these values across functions.
The lint will warn only at the definition point of the local variable. Therefore, the user has to fix all the cases when the Some value is used by himself.
Example
fntest(){let a = Some(5);// Any statements here, but the `None` value of `a` is unused, e.g.:// if a.is_some() { /* ... */ }// if let Some(_) = a { /* ... */ }}
Could be written as:
fntest(){let a = 5;}
The text was updated successfully, but these errors were encountered:
What it does
This lint would warn against using the
Option
type for local variables when theNone
value is unused.Advantage
Remove the unnecessary
Option
s makes the source code more readable and effective.Drawbacks
Option
variable as "used" if it is used as an argument of a function call, i.e. don't propagate these values across functions.Some
value is used by himself.Example
Could be written as:
The text was updated successfully, but these errors were encountered: