What it does
detect manual implementation of the next_multiple_of, e.g. a.div_ceil(b) * b. Note that this may combine clippy::manual_div_ceil detection as well, e.g. (x + (y - 1)) / y * y.
Make sure to include checked_next_multiple_of variant detection
Advantage
- shows clear intent rather
- reduces code complexity
- prevents accidental bugs
Drawbacks
No response
Example
use std::ops::Mul;
fn mult1(a: u32, b: u32) -> u32 {
a.div_ceil(b) * b
}
fn mult2(a: u32, b: u32) -> u32 {
a.div_ceil(b).mul(b)
}
fn mult3(a: u32, b: u32) -> u32 {
(a + (b - 1)) / b * b
}
Could be written as:
Comparison with existing lints
manual_div_ceil does something similar
Additional Context
No response
What it does
detect manual implementation of the
next_multiple_of, e.g.a.div_ceil(b) * b. Note that this may combine clippy::manual_div_ceil detection as well, e.g.(x + (y - 1)) / y * y.Make sure to include
checked_next_multiple_ofvariant detectionAdvantage
Drawbacks
No response
Example
Could be written as:
Comparison with existing lints
manual_div_ceil does something similar
Additional Context
No response