Expose the types usable bits as an associated constant.

This can be used for example with static_assert!() to validate
the Bounded type against bindings constants it reflects.

Signed-off-by: Thomas Weißschuh <[email protected]>
---
 rust/kernel/num/bounded.rs | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rust/kernel/num/bounded.rs b/rust/kernel/num/bounded.rs
index 2a2b0a4bca5e..4045e5aeb7dc 100644
--- a/rust/kernel/num/bounded.rs
+++ b/rust/kernel/num/bounded.rs
@@ -285,6 +285,9 @@ impl<T, const N: u32> Bounded<T, N>
 where
     T: Integer,
 {
+    /// Number of usable bits in this [`Bounded`] type.
+    pub const USABLE_BITS: u32 = N;
+
     /// Private constructor enforcing the type invariants.
     ///
     /// All instances of [`Bounded`] must be created through this method as it 
enforces most of the

-- 
2.56.0


Reply via email to