[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DBR3913BFPSK.18K4JBYOPQVRG@nvidia.com>
Date: Fri, 01 Aug 2025 21:26:22 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Christian S. Lima" <christiansantoslima21@...il.com>, "Miguel Ojeda"
<ojeda@...nel.org>, "Alex Gaynor" <alex.gaynor@...il.com>, "Boqun Feng"
<boqun.feng@...il.com>, "Gary Guo" <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>, "Benno Lossin"
<benno.lossin@...ton.me>, "Andreas Hindborg" <a.hindborg@...nel.org>,
"Alice Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>,
"Danilo Krummrich" <dakr@...nel.org>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <~lkcamp/patches@...ts.sr.ht>,
<richard120310@...il.com>
Subject: Re: [PATCH v8] rust: transmute: Add methods for FromBytes trait
Hi Christian,
Any plan for a v9 soon? I would like to make sure we secure this into
the Nova tree as we are highly dependent on this feature.
On Tue Jun 24, 2025 at 1:28 PM JST, Christian S. Lima wrote:
<snip>
> +// SAFETY: All bit patterns are acceptable values of the types and in array case if all bit patterns
> +// are acceptable for individual values in an array, then all bit patterns are also acceptable
> +// for arrays of that type.
> +unsafe impl<T> FromBytes for T
> +where
> + T: FromBytesSized,
> +{
> + fn from_bytes(bytes: &[u8]) -> Option<&Self> {
> + let slice_ptr = bytes.as_ptr().cast::<T>();
> + if bytes.len() == ::core::mem::size_of::<T>() && slice_ptr.is_aligned() {
Another small nit: this is not a macro, so you don't need to use the
`::` prefix here. Actually even `size_of::<T>()` seems to work.
Powered by blists - more mailing lists