From a2bfc9989433f3749f961a19a11a858b1b9e128f Mon Sep 17 00:00:00 2001 From: "Jorge C. Leitao" Date: Fri, 2 Jul 2021 17:43:41 +0000 Subject: [PATCH] API docs. --- src/bitmap/mutable.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bitmap/mutable.rs b/src/bitmap/mutable.rs index 850397e8cb6..c382fc4f1dc 100644 --- a/src/bitmap/mutable.rs +++ b/src/bitmap/mutable.rs @@ -9,6 +9,7 @@ use super::Bitmap; /// to [`Vec`], but each value is stored as a single bit, thereby achieving a compression of 8x. /// This container is the counterpart of [`MutableBuffer`] for boolean values. /// [`MutableBitmap`] can be converted to a [`Bitmap`] at `O(1)`. +/// The main difference against [`Vec`] is that a bitmap cannot be represented as `&[bool]`. /// # Implementation /// This container is backed by [`MutableBuffer`]. #[derive(Debug)] @@ -148,11 +149,16 @@ impl MutableBitmap { } impl MutableBitmap { + /// Initializes a [`MutableBitmap`] from a [`MutableBuffer`] and a length. + /// # Panic + /// Panics iff the length is larger than the length of the buffer times 8. #[inline] pub fn from_buffer(buffer: MutableBuffer, length: usize) -> Self { + assert!(length <= buffer.len() * 8); Self { buffer, length } } + /// Returns an iterator over the values of the [`MutableBitmap`]. fn iter(&self) -> BitmapIter { BitmapIter::new(&self.buffer, 0, self.len()) }