diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb5f83ba..f401f1f7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -94,6 +94,12 @@ jobs: command: test args: --features serde + - name: Test no default features + uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features + - name: Test benchmarks uses: actions-rs/cargo@v1 with: diff --git a/src/bitmap/arbitrary.rs b/src/bitmap/arbitrary.rs index 45d47540..a8ca25be 100644 --- a/src/bitmap/arbitrary.rs +++ b/src/bitmap/arbitrary.rs @@ -8,6 +8,11 @@ mod test { use proptest::collection::{vec, SizeRange}; use proptest::prelude::*; + #[cfg(not(feature = "std"))] + use alloc::boxed::Box; + #[cfg(not(feature = "std"))] + use alloc::vec::Vec; + impl Debug for BitmapStore { fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { if self.len() < 16 { diff --git a/src/bitmap/container.rs b/src/bitmap/container.rs index 552fff56..a28c7c67 100644 --- a/src/bitmap/container.rs +++ b/src/bitmap/container.rs @@ -8,6 +8,9 @@ use super::util; pub const ARRAY_LIMIT: u64 = 4096; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + #[derive(PartialEq, Clone)] pub struct Container { pub key: u16, diff --git a/src/bitmap/fmt.rs b/src/bitmap/fmt.rs index 096506d0..702ea998 100644 --- a/src/bitmap/fmt.rs +++ b/src/bitmap/fmt.rs @@ -2,6 +2,9 @@ use core::fmt; use crate::RoaringBitmap; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + impl fmt::Debug for RoaringBitmap { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.len() < 16 { diff --git a/src/bitmap/inherent.rs b/src/bitmap/inherent.rs index caa26506..57c3ffec 100644 --- a/src/bitmap/inherent.rs +++ b/src/bitmap/inherent.rs @@ -6,6 +6,9 @@ use crate::RoaringBitmap; use super::container::Container; use super::util; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + impl RoaringBitmap { /// Creates an empty `RoaringBitmap`. /// diff --git a/src/bitmap/iter.rs b/src/bitmap/iter.rs index ac85fa33..8e9bd276 100644 --- a/src/bitmap/iter.rs +++ b/src/bitmap/iter.rs @@ -5,6 +5,9 @@ use core::slice; use super::container::Container; use crate::{NonSortedIntegers, RoaringBitmap}; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + /// An iterator for `RoaringBitmap`. pub struct Iter<'a> { inner: iter::Flatten>, diff --git a/src/bitmap/mod.rs b/src/bitmap/mod.rs index 0fce56e2..4aebfc37 100644 --- a/src/bitmap/mod.rs +++ b/src/bitmap/mod.rs @@ -21,6 +21,9 @@ use self::cmp::Pairs; pub use self::iter::IntoIter; pub use self::iter::Iter; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + /// A compressed bitmap using the [Roaring bitmap compression scheme](https://roaringbitmap.org/). /// /// # Examples diff --git a/src/bitmap/multiops.rs b/src/bitmap/multiops.rs index e3d37b51..1982e4f3 100644 --- a/src/bitmap/multiops.rs +++ b/src/bitmap/multiops.rs @@ -11,6 +11,9 @@ use crate::{MultiOps, RoaringBitmap}; use super::{container::Container, store::Store}; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + /// When collecting bitmaps for optimizing the computation. If we don't know how many // elements are in the iterator we collect 10 elements. const BASE_COLLECT: usize = 10; diff --git a/src/bitmap/ops.rs b/src/bitmap/ops.rs index 75a2fa6a..f99a376b 100644 --- a/src/bitmap/ops.rs +++ b/src/bitmap/ops.rs @@ -5,6 +5,9 @@ use crate::bitmap::container::Container; use crate::bitmap::Pairs; use crate::RoaringBitmap; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + impl RoaringBitmap { /// Computes the len of the intersection with the specified other bitmap without creating a /// new bitmap. diff --git a/src/bitmap/store/array_store/mod.rs b/src/bitmap/store/array_store/mod.rs index 54ae7d28..6c41aadb 100644 --- a/src/bitmap/store/array_store/mod.rs +++ b/src/bitmap/store/array_store/mod.rs @@ -8,6 +8,12 @@ use core::cmp::Ordering::*; use core::fmt::{Display, Formatter}; use core::ops::{BitAnd, BitAndAssign, BitOr, BitXor, RangeInclusive, Sub, SubAssign}; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + +#[cfg(not(feature = "std"))] +use alloc::boxed::Box; + use super::bitmap_store::{bit, key, BitmapStore, BITMAP_LENGTH}; #[derive(Clone, Eq, PartialEq)] diff --git a/src/bitmap/store/array_store/visitor.rs b/src/bitmap/store/array_store/visitor.rs index b092e6cf..51dda9b9 100644 --- a/src/bitmap/store/array_store/visitor.rs +++ b/src/bitmap/store/array_store/visitor.rs @@ -1,6 +1,9 @@ #[cfg(feature = "simd")] use crate::bitmap::store::array_store::vector::swizzle_to_front; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + /// This visitor pattern allows multiple different algorithms to be written over the same data /// For example: vectorized algorithms can pass a visitor off to a scalar algorithm to finish off /// a tail that is not a multiple of the vector width. diff --git a/src/bitmap/store/bitmap_store.rs b/src/bitmap/store/bitmap_store.rs index ca21e1f9..731fc929 100644 --- a/src/bitmap/store/bitmap_store.rs +++ b/src/bitmap/store/bitmap_store.rs @@ -5,6 +5,11 @@ use core::ops::{BitAndAssign, BitOrAssign, BitXorAssign, RangeInclusive, SubAssi use super::ArrayStore; +#[cfg(not(feature = "std"))] +use alloc::boxed::Box; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + pub const BITMAP_LENGTH: usize = 1024; #[derive(Clone, Eq, PartialEq)] diff --git a/src/bitmap/store/mod.rs b/src/bitmap/store/mod.rs index 4cba870b..25426295 100644 --- a/src/bitmap/store/mod.rs +++ b/src/bitmap/store/mod.rs @@ -16,6 +16,9 @@ pub use self::bitmap_store::{BitmapIter, BitmapStore}; use crate::bitmap::container::ARRAY_LIMIT; +#[cfg(not(feature = "std"))] +use alloc::boxed::Box; + #[derive(Clone)] pub enum Store { Array(ArrayStore), diff --git a/src/treemap/fmt.rs b/src/treemap/fmt.rs index 3c36b72b..4a330087 100644 --- a/src/treemap/fmt.rs +++ b/src/treemap/fmt.rs @@ -2,6 +2,9 @@ use core::fmt; use crate::RoaringTreemap; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + impl fmt::Debug for RoaringTreemap { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.len() < 16 { diff --git a/src/treemap/inherent.rs b/src/treemap/inherent.rs index e1190931..9db01ebf 100644 --- a/src/treemap/inherent.rs +++ b/src/treemap/inherent.rs @@ -7,6 +7,9 @@ use crate::RoaringTreemap; use super::util; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + impl RoaringTreemap { /// Creates an empty `RoaringTreemap`. /// diff --git a/src/treemap/multiops.rs b/src/treemap/multiops.rs index c50b8530..39c6e15f 100644 --- a/src/treemap/multiops.rs +++ b/src/treemap/multiops.rs @@ -3,6 +3,9 @@ use core::{borrow::Borrow, cmp::Ordering, mem}; use crate::{MultiOps, RoaringBitmap, RoaringTreemap}; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + impl MultiOps for I where I: IntoIterator, diff --git a/src/treemap/ops.rs b/src/treemap/ops.rs index f1a25a2f..9bf9a5a9 100644 --- a/src/treemap/ops.rs +++ b/src/treemap/ops.rs @@ -4,6 +4,9 @@ use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, use crate::RoaringTreemap; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; + impl RoaringTreemap { /// Computes the len of the union with the specified other treemap without creating a new /// treemap.