Re: [PATCH v2] rust: impl_flags: add conversions for raw flag representations

From: Andreas Hindborg

Date: Wed Sep 30 2026 - 17:20:28 EST


Filipe Xavier <felipeaggger@xxxxxxxxx> writes:

> Extend the impl_flags! macro to support conversions between generated flag
> types and raw C/UAPI integers. Implement TryFrom<Repr> for individual flags
> (exact variant match) and flag sets (rejecting unknown bits), along with an
> unsafe from_raw() constructor for flag sets. Additionally, add BitOr and
> BitOrAssign implementations between the raw representation and flag types.
>
> Suggested-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
> Suggested-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
> Signed-off-by: Filipe Xavier <felipeaggger@xxxxxxxxx>

I feel like I already sent a patch for at least part of this [1]. Please
go review that one and maybe use it as a dependency.

Best regards,
Andreas Hindborg

[1] https://lore.kernel.org/all/20260605-impl-flags-additions-v2-1-0d27242f460b@xxxxxxxxxx/