Re: [PATCH] rust: impl_flags: add method to return underlying integer
From: Andreas Hindborg
Date: Sat Feb 14 2026 - 03:18:45 EST
Gary Guo <gary@xxxxxxxxxxx> writes:
> On 2026-02-12 16:02, Andreas Hindborg wrote:
>> Add a method to return the underlying integer used for flags. This is
>> useful when using the flags with C APIs.
>>
>> Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
>
> I am not sure if we want to actually expose the underlying representation
> for all flags. It should be something up to the caller of `impl_flags` to
> decide.
>
> Would it make sense to add visibility the wrapped raw type so that you
> can do
>
> impl_flags! {
> pub struct Foo(pub u32);
> ...
> }
>
> to make the inner accessible?
I don't see how that is better?
bindings::blk_mq_tag_set {
...
flags: flags.into_inner(),
...
}
vs
bindings::blk_mq_tag_set {
...
flags: flags.0,
...
}
I would prefer the first one.
We are going to need to be able to pass these flags into C APIs. I feel
like adding a method to do this is the best way to go about this. We can
call it something else if that communicates the purpose better.
Best regards,
Andreas Hindborg