On Wed Jul 16, 2025 at 7:32 PM CEST, Daniel Almeida 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]. Instead of the match this can use genmask_checked_u64() and convert the Option to a Result, once genmask is upstream. > You should also get a compile-time failure if n is out of bounds by default using > genmask. No, we can't use genmask_u64(), `n` is not guaranteed to be known at compile time, so we'd need to use genmask_checked_u64(). Of course, we could have a separate DmaMask constructor, e.g. with a const generic -- not sure that's worth though.