]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: transmute: add `as_bytes_mut` method to `AsBytes` trait
authorAlexandre Courbot <acourbot@nvidia.com>
Fri, 1 Aug 2025 13:24:10 +0000 (22:24 +0900)
committerAlexandre Courbot <acourbot@nvidia.com>
Fri, 22 Aug 2025 00:49:01 +0000 (09:49 +0900)
commit331c24e6ce814af2af74bac648d1ac1708873e9c
treeb51c4aebc3301d8a9b611c5f12bc9ca48d417074
parent1db476d294c031c38d3e5cbc4d41faf6dfd77ffb
rust: transmute: add `as_bytes_mut` method to `AsBytes` trait

Types that implement both `AsBytes` and `FromBytes` can be safely
modified as a slice of bytes. Add a `as_bytes_mut` method for that
purpose.

[acourbot@nvidia.com: use fully qualified `core::mem::size_of_val` to
build with Rust 1.78.]

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://lore.kernel.org/r/20250801-as_bytes-v5-2-975f87d5dc85@nvidia.com
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
rust/kernel/transmute.rs