Closed
Description
What it does
In todays AdventOfCode i caught myself using the below example.
The max()
call of an unsigned number with 0 is unnecessary.
It would be nice if clippy would say something about that.
the maximum between 0 and an unsigned number is always the number.
Please let me know if i did anything wrong.
Have a nice day.
Advantage
- Remove of unnecessary function call
- Reduction of Code Complexity
Drawbacks
No response
Example
let x: usize = 5;
let y: usize = 8;
let ret = 0.max(x.saturating_sub(y));
Could be written as:
let x: usize = 5;
let y: usize = 8;
let ret = x.saturating_sub(y);