Re: [PATCH v7 05/10] rust: io: add IoLoc and IoWrite types
From: Danilo Krummrich
Date: Wed Mar 04 2026 - 17:25:53 EST
On Wed Mar 4, 2026 at 11:15 PM CET, Gary Guo wrote:
> On Wed Mar 4, 2026 at 9:38 PM GMT, Danilo Krummrich wrote:
>> bar.write(regs::MyReg, regs::MyReg::foo())
>
> This specific case is indeed more cumbersome with the two argument approach,
> although given Alex's nova diff I think the occurance shouldn't be that
> frequent.
>
> It's also not that the two argument approach would preclude us from having a
> single argument option. In fact, with the two-argument design as the basis, we
> can implement such a helper function cleaner than Alex's PATCH 10/10 (which uses
> `Into<IoWrite>`:
>
> /// Indicates that this type is always associated with a specific fixed I/O
> /// location.
> ///
> /// This allows use of `io.bikeshed_shorthand_name(value)` instead of specifying
> /// the register name explicitly `io.write(REG, value)`.
> trait FixedIoLocation {
> type IoLocType: IoLoc<Self>;
> const IO_LOCATION: Self::IoLocType;
> }
>
> trait Io {
> fn bikeshed_shorthand_name<T>(&self, value: T)
What about write()? :P
> where T: FixedIoLocation +
> Self: IoCapable<<T::IoLocType as IoLoc<T>>::IoType>,
> {
> self.write(T::IO_LOCATION, value)
> }
> }
Ok, please go ahead with this then.