[PATCH v4 12/20] rust: prelude: add `zerocopy{,_derive}::IntoBytes`

From: Gary Guo

Date: Thu Jun 11 2026 - 12:47:08 EST


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>
---
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.
---
rust/kernel/prelude.rs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs
index 8a6da92e8da6..ca396f1f78a6 100644
--- a/rust/kernel/prelude.rs
+++ b/rust/kernel/prelude.rs
@@ -61,10 +61,16 @@
};

#[doc(no_inline)]
-pub use zerocopy::FromBytes;
+pub use zerocopy::{
+ FromBytes,
+ IntoBytes, //
+};

#[doc(no_inline)]
-pub use zerocopy_derive::FromBytes;
+pub use zerocopy_derive::{
+ FromBytes,
+ IntoBytes, //
+};

#[doc(no_inline)]
pub use super::{

--
2.54.0