Re: [PATCH 3/6] rust: add `bitfield!` macro
From: John Hubbard
Date: Tue Jan 27 2026 - 20:41:39 EST
On 1/27/26 5:28 PM, Alexandre Courbot wrote:
> On Wed Jan 28, 2026 at 6:10 AM JST, Gary Guo wrote:
>> On Tue Jan 27, 2026 at 9:03 PM GMT, John Hubbard wrote:
>>> On 1/27/26 1:57 AM, Alexandre Courbot wrote:
>>>> On Tue Jan 27, 2026 at 11:55 AM JST, Yury Norov wrote:
>>>> <snip>
>> Given the signature in the API I would agree with Yury that `with_` is better.
>
> Indeed, given the signature of the method `with_` is definitely more
> idiomatic. But that is also true for the non-const setter, and they
> unfortunately cannot share the same name.
>
oh that is unfortunate.
> Alternative names I can think of for the non-const / const setters:
>
> - `with_foo`/`with_foo_const`, but that's a bit verbose,
Yes, but it is also at least slightly self-explanatory: "the name
is a little ugly, but you can see what it is for".
> - `with_foo`/`const_foo`, but that's not idiomatic either,
> - `with_foo_val`/`with_foo`, but that increases the risk of name
> clashes.
>
> ... so unless there are better proposals I guess the
> `set_foo`/`with_foo` is at least practical, if a bit unconventional.
...whereas this choice just looks unhinged, at first glance:
"what? whhhyyy???" haha :)
And eventually the reader figures out why. Maybe.
thanks,
--
John Hubbard