summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2026-09-01 17:50:27 +0100
committerDanilo Krummrich <dakr@kernel.org>2026-09-06 13:39:44 +0200
commitef605a433d80987e97fcf62a41bdf437abc61e2c (patch)
treef57c5f702231b775fe1151363bc3c1837e1a7eb7 /scripts
parent1fc1f82756b1ff872c04950747925f7dcf5c1d8a (diff)
downloadlinux-next-ef605a433d80987e97fcf62a41bdf437abc61e2c.tar.gz
linux-next-ef605a433d80987e97fcf62a41bdf437abc61e2c.zip
rust: mem: add `AsRepr` and `AsReprMut`
Some API like atomics and I/O operate on primitives only; therefore other types would need to converted to these primitive first. Add two traits `AsRepr` and `AsReprMut` to indicate that the type can be turned into a primitive for these operations. `T: AsRepr` means that `&T` can be viewed as `&T::Repr` and thus it needs to support transmutability in one direction. `T: AsReprMut` means that `&mut T` can be viewed as `&mut T::Repr` and thus it needs to support bi-directional transmutability. To avoid duplicating implementations, all repr types are normalized to unsigned integers. Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Tested-by: Alexandre Courbot <acourbot@nvidia.com> Acked-by: Miguel Ojeda <ojeda@kernel.org> Link: https://patch.msgid.link/20260901-typed_register-v4-3-5552b1d59525@garyguo.net [ Fix grammar in from_repr_unchecked() documentation, rephrase confusing safety comment, use rustdoc links for Self, fix backtick formatting in comments and use consistent 'must' wording in safety sections. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions