Re: [PATCH v7] rust: add new macro for common bitmap operations

From: Miguel Ojeda
Date: Sat Jan 03 2026 - 09:00:50 EST


On Sat, Jan 3, 2026 at 2:15 AM Kari Argillander
<kari.argillander@xxxxxxxxx> wrote:
>
> But probably there is no point continue discussion as two people has nacked
> my suggestion so fast and I'm totally ok with it. Still thanks for
> taking time on this.

In general, I think it is a good point, i.e. I agree that abusing
custom operators everywhere isn't great, just like having a lot of
macros with custom, non-obvious syntax isn't ideal.

For something like bitflags, however, it seems reasonable. I think it
is a balance. For instance, `.enable()` and `.toggle()` are common in
other domains especially with a single flag/concept as an argument,
but when working with bitflags developers will likely expect to be
able to use the usual expressions they are accustomed to, especially
in a context like the Linux kernel. And while the `|` approach would
be workable if you introduce more methods like the masking case etc.,
something else like `.toggle(A & B)` would be very, very confusing,
i.e. it is like going back to square one introducing custom syntax
again.

Thanks for raising the point -- it is always nice to consider more
viewpoints and having more reviews.

Cheers,
Miguel