diff options
Diffstat (limited to 'rust/kernel/bitmap.rs')
| -rw-r--r-- | rust/kernel/bitmap.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/rust/kernel/bitmap.rs b/rust/kernel/bitmap.rs index 0705646c6251..83d7dea99137 100644 --- a/rust/kernel/bitmap.rs +++ b/rust/kernel/bitmap.rs @@ -230,6 +230,16 @@ impl BitmapVec { /// The maximum length that uses the inline representation. pub const MAX_INLINE_LEN: usize = usize::BITS as usize; + /// Construct a longest possible inline [`BitmapVec`]. + #[inline] + pub fn new_inline() -> Self { + // INVARIANT: `nbits <= MAX_INLINE_LEN`, so an inline bitmap is the right repr. + BitmapVec { + repr: BitmapRepr { bitmap: 0 }, + nbits: BitmapVec::MAX_INLINE_LEN, + } + } + /// Constructs a new [`BitmapVec`]. /// /// Fails with [`AllocError`] when the [`BitmapVec`] could not be allocated. This |
