]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: transmute: implement FromBytes and AsBytes for inhabited ZSTs
authorAlexandre Courbot <acourbot@nvidia.com>
Mon, 15 Dec 2025 05:49:09 +0000 (14:49 +0900)
committerMiguel Ojeda <ojeda@kernel.org>
Mon, 26 Jan 2026 02:16:31 +0000 (03:16 +0100)
commit209c70953aa3630eb25e93e95464306a41b16d12
tree5e9e53cbcc1a9c31e17d02b12cb7e79b06b9cfe2
parent7f87c7a003125d5af5ec7abbbc0ac21b4a4661ae
rust: transmute: implement FromBytes and AsBytes for inhabited ZSTs

This is useful when using types that may or may not be empty in generic
code relying on these traits. It is also safe because technically a
no-op.

Reviewed-by: Alistair Popple <apopple@nvidia.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20251215-transmute_unit-v4-1-477d71ec7c23@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/transmute.rs