rust-num / num-traits

Numeric traits for generic mathematics in Rust
Apache License 2.0
694 stars 131 forks source link

Adding {ilog, ilog2, ilog10} to PrimInt #313

Open Elizafox opened 5 months ago

Elizafox commented 5 months ago

This is a breaking change, but one in line with how the language has evolved.

{ilog, ilog2, ilog10} should all be methods in PrimInt. These have been stable for almost 2 years.

Also probably the checked variants, too.

The signatures are essentially

pub const fn ilog(self) -> u32;
pub const fn ilog2(self) -> u32;
pub const fn ilog10(self) -> u32;

EDIT: as a stopgap, these could go in a ILog trait and just be there for use to avoid breaking everything.

cuviper commented 5 months ago

They can go on PrimInt if you can figure out generic default implementations.