Suggest to replace int_as_float.log{|2|10}().floor() as u32
with int.ilog{|2|10}()
#13699
Labels
A-lint
Area: New lints
What it does
Search for redundant$\lfloor \log_b n \rfloor$ for a integer $n$ .
25_i32.ilog(5)
instead of(25_i32 as f64).log(5.0).floor() as u32
.8_i32.ilog2()
instead of(8_i32 as f64).log2().floor() as u32
.100_i32.ilog10()
instead of(100_i32 as f64).log10().floor() as u32
.ilog{|2|10}
areconst fn
, butlog{|2|10}
andfloor
are not.Advantage
Drawbacks
MSRV is 1.67.0.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: