RS.CLIPPY.UNNECESSARY_MIN_OR_MAX
Using 'min()/max()' when there is no need for it
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: unnecessary_min_or_max. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for unnecessary calls to min() or max() in the following cases
- Either both side is constant
- One side is clearly larger than the other, like i32::MIN and an i32 variable
Why is this bad?
In the aforementioned cases it is not necessary to call min() or max()
to compare values, it may even cause confusion.
Example
let _ = 0.min(7_u32);
Use instead:
let _ = 0;