Re: [PATCH v7] rust: transmute: Add methods for FromBytes trait
From: Alexandre Courbot
Date: Tue Jun 17 2025 - 03:40:05 EST
On Tue Jun 17, 2025 at 10:55 AM JST, Christian wrote:
>> Or if that is still unclear, consider the following doctest in `dma.rs`
>> that fails with this patch:
>>
>> struct MyStruct { field: u32, }
>>
>> // SAFETY: All bit patterns are acceptable values for `MyStruct`.
>> unsafe impl kernel::transmute::FromBytes for MyStruct{};
>> // SAFETY: Instances of `MyStruct` have no uninitialized portions.
>> unsafe impl kernel::transmute::AsBytes for MyStruct{};
>>
>> It fails because the `FromBytes` implementation for `MyStruct` does not provide
>> a definition for `from_bytes` and `from_mut_bytes`. Fixing this is just a
>> matter of changing the `impl FromBytes` into `impl FromBytesSized`. But without
>> the latter, how do you make this example build without providing a definition
>> of `from_bytes` and `from_bytes_mut`?
>
> Well, that's fine with me. I'll send the next patch with this fix. Can
> I put it as `suggested-by`?
If you think it is appropriate, sure!