Skip to content

Commit

Permalink
Fixes for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Emann committed Mar 22, 2024
1 parent 777a7a7 commit f20478d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
6 changes: 6 additions & 0 deletions croaring/src/bitmap/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ use std::mem::MaybeUninit;

use super::Bitmap;

/// A cusrsr over the values of a bitmap
///
/// A Cursor is like an iterator, except that it can freely seek back-and-forth.
///
/// A cursor points at a single value in the bitmap, or at a "ghost" position,
/// either one before the beginning of the bitmap, or one after the end of the bitmap.
#[derive(Clone)]
pub struct BitmapCursor<'a> {
raw: ffi::roaring_uint32_iterator_t,
Expand Down
2 changes: 1 addition & 1 deletion croaring/src/bitmap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ mod ops;
mod serialization;
mod view;

pub use self::iter::BitmapIterator;
pub use self::iter::{BitmapCursor, BitmapIterator};
pub use self::lazy::LazyBitmap;
pub use self::serialization::{Deserializer, Serializer, ViewDeserializer};
6 changes: 3 additions & 3 deletions croaring/src/bitmap/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ pub trait Deserializer {
///
/// # Safety
///
/// Unlike its safe counterpart, [`try_deserialize`], this function assumes the data is valid,
/// passing data which does not contain/start with a bitmap serialized with this format will
/// result in undefined behavior.
/// Unlike its safe counterpart ([`Self::try_deserialize`]) this function assumes the data is
/// valid, passing data which does not contain/start with a bitmap serialized with this format
/// will result in undefined behavior.
unsafe fn try_deserialize_unchecked(buffer: &[u8]) -> Bitmap;
}

Expand Down
17 changes: 17 additions & 0 deletions croaring/src/bitmap64/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,23 @@ impl Bitmap64 {
unsafe { ffi::roaring64_bitmap_remove_range_closed(self.raw.as_ptr(), start, end) }
}

/// Empty the bitmap
///
/// # Examples
///
/// ```
/// use croaring::Bitmap64;
///
/// let mut bitmap = Bitmap64::from([1, 2, 3]);
/// assert!(!bitmap.is_empty());
/// bitmap.clear();
/// assert!(bitmap.is_empty());
/// ```
#[inline]
pub fn clear(&mut self) {
self.remove_range(..);
}

/// Returns the number of values in the bitmap
///
/// # Examples
Expand Down
8 changes: 4 additions & 4 deletions croaring/src/bitmap64/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::num::NonZeroUsize;
pub trait Serializer {
/// Serialize a bitmap into bytes, using the provided vec buffer to store the serialized data
///
/// Note that some serializers ([Frozen]) may require that the bitmap is aligned specially,
/// this method will ensure that the returned slice of bytes is aligned correctly, by adding
/// additional padding before the serialized data if required.
/// Note that some serializers ([Frozen][crate::Frozen]) may require that the
/// bitmap is aligned specially, this method will ensure that the returned slice of bytes is
/// aligned correctly, by adding additional padding before the serialized data if required.
///
/// The contents of the provided vec buffer will not be overwritten: only new data will be
/// appended to the end of the buffer. If the buffer has enough capacity, and the current
Expand Down Expand Up @@ -41,7 +41,7 @@ pub trait Deserializer {
///
/// # Safety
///
/// Unlike its safe counterpart, [`try_deserialize`], this function assumes the data is valid,
/// Unlike its safe counterpart, [`Self::try_deserialize`], this function assumes the data is valid,
/// passing data which does not contain/start with a bitmap serialized with this format will
/// result in undefined behavior.
unsafe fn try_deserialize_unchecked(buffer: &[u8]) -> Bitmap64;
Expand Down

0 comments on commit f20478d

Please sign in to comment.