diff options
| author | Alexandre Courbot <acourbot@nvidia.com> | 2025-11-08 11:23:48 +0900 |
|---|---|---|
| committer | Miguel Ojeda <ojeda@kernel.org> | 2025-11-19 00:22:24 +0100 |
| commit | 01e345e82ec3a5a7edeb9fa0dcb7fd4b0e5c534e (patch) | |
| tree | 99385318f9e308381ef2a313fbc452a455b88e71 /rust/kernel/num.rs | |
| parent | 90f3df4fdfb682e2394ee3f97dfe91a402d5c46a (diff) | |
rust: num: add Bounded integer wrapping type
Add the `Bounded` integer wrapper type, which restricts the number of
bits allowed to represent of value.
This is useful to e.g. enforce guarantees when working with bitfields
that have an arbitrary number of bits.
Alongside this type, provide many `From` and `TryFrom` implementations
are to reduce friction when using with regular integer types. Proxy
implementations of common integer operations are also provided.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20251108-bounded_ints-v4-2-c9342ac7ebd1@nvidia.com
[ Added intra-doc link. Fixed a few other nits. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/num.rs')
| -rw-r--r-- | rust/kernel/num.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/rust/kernel/num.rs b/rust/kernel/num.rs index c8c91cb9e682..8532b511384c 100644 --- a/rust/kernel/num.rs +++ b/rust/kernel/num.rs @@ -4,6 +4,9 @@ use core::ops; +pub mod bounded; +pub use bounded::*; + /// Designates unsigned primitive types. pub enum Unsigned {} |
