Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issues with no std #279

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions src/bitmap/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions src/bitmap/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/bitmap/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions src/bitmap/inherent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
///
Expand Down
3 changes: 3 additions & 0 deletions src/bitmap/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<slice::Iter<'a, Container>>,
Expand Down
3 changes: 3 additions & 0 deletions src/bitmap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/bitmap/multiops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/bitmap/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions src/bitmap/store/array_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
3 changes: 3 additions & 0 deletions src/bitmap/store/array_store/visitor.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 5 additions & 0 deletions src/bitmap/store/bitmap_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
3 changes: 3 additions & 0 deletions src/bitmap/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions src/treemap/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions src/treemap/inherent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use crate::RoaringTreemap;

use super::util;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

impl RoaringTreemap {
/// Creates an empty `RoaringTreemap`.
///
Expand Down
3 changes: 3 additions & 0 deletions src/treemap/multiops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<I> MultiOps<RoaringTreemap> for I
where
I: IntoIterator<Item = RoaringTreemap>,
Expand Down
3 changes: 3 additions & 0 deletions src/treemap/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading