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
Right now, the lint checks for patterns with checked_add and unwrap_or. It could perhaps be extended (or it could be a new lint which covers manual wrapping or checked arithmetic as well) to also check for other patterns that don't use checked_add. For example with unsigned integers:
let result = if a > b { a - b }else{0};
which could be rewritten as:
let result = a.saturating_sub(b);
Lint Name
manual_saturating_arithmetic
Category
complexity
Advantage
simpler code
more coverage over the original lint
Drawbacks
more complex checking
Example
let result = if a > b { a - b }else{0};
Could be written as:
let result = a.saturating_sub(b);
The text was updated successfully, but these errors were encountered:
What it does
Right now, the lint checks for patterns with
checked_add
andunwrap_or
. It could perhaps be extended (or it could be a new lint which covers manual wrapping or checked arithmetic as well) to also check for other patterns that don't usechecked_add
. For example with unsigned integers:which could be rewritten as:
Lint Name
manual_saturating_arithmetic
Category
complexity
Advantage
Drawbacks
Example
Could be written as:
The text was updated successfully, but these errors were encountered: