Re: [PATCH v9] rust: kernel: add support for bits/genmask macros

From: Daniel Almeida
Date: Wed Jul 16 2025 - 15:19:12 EST



>
>>
>> (3) OOC, why did you choose u32 as argument type?
>
> No reason. i32 is the default integer type and signed integers don’t make
> sense here, so I chose u32.
>
> Also, we can trivially promote integers to wider types, but the other way
> around is not true. So my reasoning was that if you had u8, or u16s you could
> trivially get u32s using into(), but if you had u32s and e.g. genmask_u16
> required u16s, you'd have to resort to try_into() or `as`, which is annoying.
>
> In any case, feel free to suggest anything else, I think.
>
> — Daniel

I guess that, using the logic above, one could ask "why not u64 then?".

64bit variables are less commonly used, so this would be the inverse
problem, i.e.: we'd see way too many uses of into().

— Daniel