mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rust: prelude: add `zerocopy{,_derive}::IntoBytes`
@ 2026-06-11 13:48 Gary Guo
  2026-06-16 23:30 ` Miguel Ojeda
  0 siblings, 1 reply; 2+ messages in thread
From: Gary Guo @ 2026-06-11 13:48 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich
  Cc: rust-for-linux, linux-kernel

From: Gary Guo <gary@garyguo.net>

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@garyguo.net>
---
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 ca260cc3937a..a97cb0af5d02 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::{

base-commit: 98cc68794c003bc76fc9da2e8a075e947eee5921
-- 
2.54.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] rust: prelude: add `zerocopy{,_derive}::IntoBytes`
  2026-06-11 13:48 [PATCH] rust: prelude: add `zerocopy{,_derive}::IntoBytes` Gary Guo
@ 2026-06-16 23:30 ` Miguel Ojeda
  0 siblings, 0 replies; 2+ messages in thread
From: Miguel Ojeda @ 2026-06-16 23:30 UTC (permalink / raw)
  To: Gary Guo
  Cc: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	rust-for-linux, linux-kernel

On Thu, Jun 11, 2026 at 3:48 PM Gary Guo <gary@kernel.org> 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@garyguo.net>

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@garyguo.net/

          - 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-16 23:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-11 13:48 [PATCH] rust: prelude: add `zerocopy{,_derive}::IntoBytes` Gary Guo
2026-06-16 23:30 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®