RS.CLIPPY.IMPLICIT_SATURATING_SUB
Perform saturating subtraction instead of implicitly checking lower bound of data type
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: implicit_saturating_sub. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for implicit saturating subtraction.
Why is this bad?
Simplicity and readability. Instead we can easily use an builtin function.
Example
let mut i: u32 = end - start;
if i != 0 {
i -= 1;
}
Use instead:
let mut i: u32 = end - start;
i = i.saturating_sub(1);