Skip to content

Commit

Permalink
feat: add From<Bitmap> for Bitmap64
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Emann committed Sep 19, 2024
1 parent 4bab7ec commit 0bcef52
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion croaring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ roaring = "0.10"
criterion = { version = "0.5", features = ["html_reports"] }

[dependencies]
ffi = { package = "croaring-sys", path = "../croaring-sys", version = "~4.1.1" }
ffi = { package = "croaring-sys", path = "../croaring-sys", version = "~4.1.4" }

[[bench]]
name = "benches"
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 @@ -67,7 +67,7 @@ use core::marker::PhantomData;
// &BitmapView and &Bitmap
#[repr(transparent)]
pub struct Bitmap {
bitmap: ffi::roaring_bitmap_t,
pub(crate) bitmap: ffi::roaring_bitmap_t,
}

unsafe impl Sync for Bitmap {}
Expand Down
8 changes: 7 additions & 1 deletion croaring/src/bitmap64/ops.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::Bitmap64;
use crate::{Bitmap, Bitmap64};
use core::fmt;
use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Sub, SubAssign};
use ffi::roaring64_bitmap_copy;
Expand Down Expand Up @@ -45,6 +45,12 @@ impl From<&'_ [u64]> for Bitmap64 {
}
}

impl From<Bitmap> for Bitmap64 {
fn from(mut value: Bitmap) -> Self {
unsafe { Self::take_heap(ffi::roaring64_bitmap_move_from_roaring32(&mut value.bitmap)) }
}
}

impl<const N: usize> From<[u64; N]> for Bitmap64 {
#[inline]
#[doc(alias = "roaring64_bitmap_of_ptr")]
Expand Down

0 comments on commit 0bcef52

Please sign in to comment.