Re: [PATCH] rust: prelude: add `zerocopy{,_derive}::IntoBytes`

From: Miguel Ojeda

Date: Tue Jun 16 2026 - 19:31:12 EST


On Thu, Jun 11, 2026 at 3:48 PM Gary Guo <gary@xxxxxxxxxx> wrote:
>
> In order to easily use `IntoBytes`, add it to the prelude.
>
> This adds both the trait (`zerocopy::IntoBytes`) as well as the derive
> macro (`zerocopy_derive::IntoBytes`).
>
> Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>

Applied to `rust-next` (for a potential second PR to Linus) -- thanks!

[ This patch will simplify using the feature in several trees next cycle.

Gary writes:

This is wanted because I want to convert the upcoming I/O projection
series to use `zerocopy` traits rather than keep using transmute
module.

It is most helpful for derives in doc tests; I do not want to
explicitly use `#[derive(zerocopy_derive::IntoBytes)]` in the
doc tests.

For reference, the upcoming I/O projection series is at:

https://lore.kernel.org/rust-for-linux/20260611-io_projection-v4-0-1f7224b02dcb@xxxxxxxxxxx/

- Miguel ]

There should no build errors from what I tested, but if there are, we
should discover them during this week or so. Worst case, we drop the
trait and keep the derive as discussed.

Cheers,
Miguel