> On 16 Jul 2025, at 14:32, Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx> wrote: > > Hi Danilo, > >> + #[inline] >> + pub const fn new(n: usize) -> Result<Self> { >> + Ok(Self(match n { >> + 0 => 0, >> + 1..=64 => u64::MAX >> (64 - n), >> + _ => return Err(EINVAL), >> + })) >> + } >> + > > Isn’t this equivalent to genmask_u64(0..=n) ? See [0]. > > You should also get a compile-time failure if n is out of bounds by default using > genmask. > > — Daniel > > [0]: https://lore.kernel.org/rust-for-linux/20250714-topics-tyr-genmask2-v9-1-9e6422cbadb6@xxxxxxxxxxxxx/#r Or genmask_u64(0..=n-1), if we disregard the previous off-by-one error — Daniel