Re: [PATCH v7 05/10] rust: io: add IoLoc and IoWrite types

From: Danilo Krummrich

Date: Fri Feb 27 2026 - 13:17:31 EST


On Fri Feb 27, 2026 at 7:02 PM CET, Gary Guo wrote:
> Thinking about this again, I think we might still want to write
>
> io.write(REGISTER, value)

I'm not convinced about this; it feels like optimizing for the less common case.

> Granted, this does mean that we will write `REGISTER` twice in some cases:

I'd rather say in most cases, i.e. most registers do consist out of multiple
fields.

> io.write(REGISTER, REGISTER::default().with_field(foo));
>
> But, we have no redundancy for the update case:
>
> io.update(REGISTER, |v| v.with_field(foo));
>
> The reason for this thought is that conceptually, the type of a register is not
> necessarily coupled with the register itself. This is the case currently for
> register arrays, but also the case when we think in the long term where
> bitfields become decoupled from `register!`. People also might just want to
> define a register of u32 without any bitfields at all, and in this case writing
>
> io.write(REGISTER, u32_value)

It could also be written as

io.write(Register(u32_value))

but I also think that the below is acceptable.

> looks nicer than
>
> io.write(REGISTER.set(u32_value))