Re: [PATCH v8 07/10] rust: io: introduce `IntoIoVal` trait and single-argument `write_val`

From: Danilo Krummrich

Date: Wed Mar 11 2026 - 12:25:32 EST


On Wed Mar 11, 2026 at 4:42 PM CET, Gary Guo wrote:
> On Wed Mar 11, 2026 at 2:56 PM GMT, Danilo Krummrich wrote:
>>
>> fn write<T, L>(&self, location: L, value: T)
>> where
>> L: IoLoc<T>,
>> Self: IoKnownSize + IoCapable<L::IoType>,
>>
>> Which is the reason why L: IoLoc<T>, i.e. the relative location is on T, not on
>> L.
>
> The location has nothing to do with `value`, just the type `T`.

(Cutting all the above, since it all boils down to the same thing.)

So, that's what I mean, the relative location is on type T (the value type), not
on L (the location type), hence T can't just be an arbitrary primitive, no?

>> So, what you could say is
>>
>> - read() takes an absolute location and returns something that encodes a value
>> and relative location
>>
>> - write() takes a base location (or absolute location) and something that
>> encodes a value and relative location
>
> Only `location` gives you the location. Value has nothing to do with locations at all. Type
> inference does the trick.

The value does have something to do with the relative location, as it comes from
the value type. You can't pass an "independent" value whose type does not carry
location information, can you?