Re: [PATCH v7] rust: transmute: Add methods for FromBytes trait
From: Christian
Date: Mon Jun 16 2025 - 21:55:32 EST
> 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`?
Thanks,
Christian