RS.CLIPPY.IMPLICIT_SATURATING_ADD
Perform saturating addition instead of implicitly checking max 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_add. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for implicit saturating addition.
Why is this bad?
The built-in function is more readable and may be faster.
Example
let mut u:u32 = 7000;
if u != u32::MAX {
u += 1;
}
Use instead:
let mut u:u32 = 7000;
u = u.saturating_add(1);