Re: [PATCH 1/7] rust: dma: add from-slice constructors for Coherent and CoherentBox

From: Andreas Hindborg

Date: Tue Mar 24 2026 - 10:30:11 EST


"Alexandre Courbot" <acourbot@xxxxxxxxxx> writes:

> A very common pattern is to create a block of coherent memory with the
> content of an already-existing slice of bytes (e.g. a loaded firmware
> blob).
>
> `CoherentBox` makes this easier, but still implies a potentially
> panicking operation with `copy_from_slice` that requires a `PANIC`
> comment.
>
> Add `from_slice_with_attrs` and `from_slice` methods to both `Coherent`
> and `CoherentBox` to turn this into a trivial one-step operation.
>
> Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>

Reviewed-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>

I like `?` more than `.map()` as well, but it's fine to me either way.


Best regards,
Andreas Hindborg