Re: [PATCH v2] rust: impl_flags: add method to return underlying integer
From: Miguel Ojeda
Date: Sun Jun 07 2026 - 12:30:51 EST
On Sat, Jun 6, 2026 at 2:22 PM Gary Guo <gary@xxxxxxxxxxx> wrote:
>
> I think I suggested this approach because I don't want people to be able to
> easily be able to get integers while enums could be used. But I didn't know that
> the `From` impl already exists for flags.
>
> Given the case we could probably just unconditionally expose the `bits` method
> (and whatever mechanism we use to avoid exposing bits would also remove the
> From/TryFrom/bits/all_bits/...)
I see, so having it really private. That makes more sense, including
the `pub` word. Someone may still expect the field to be actually
public, but at least it makes sense, and using `enum`s and guiding
users to avoid exposing things they don't need to expose is usually
good a good principle.
Maybe another word (like your flavors in the other series :) could
also work... But I don't mind `pub` too much if the other option is
truly private.
Cheers,
Miguel