Skip to content

more no_std support #471

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ test = false

[dependencies]
either = { version = "1.0", default-features = false }
hashbrown = { version = "0.8", optional = true}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hashbrown doesn't seem to have a minimum-supported-Rust-version policy—Itertools does. We therefore can't just drop-in hashbrown as an alternative to std::collections::HashMap.


[dev-dependencies]
rand = "0.7"
Expand All @@ -38,6 +39,7 @@ version = "0.2"

[features]
default = ["use_std"]
use_alloc = ["hashbrown"]
use_std = []

[profile]
Expand Down
1 change: 0 additions & 1 deletion src/adaptors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub use self::coalesce::*;
pub use self::map::{map_into, map_ok, MapInto, MapOk};
#[allow(deprecated)]
pub use self::map::MapResults;
#[cfg(feature = "use_std")]
pub use self::multi_product::*;

use std::fmt;
Expand Down
2 changes: 1 addition & 1 deletion src/adaptors/multi_product.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg(feature = "use_std")]

use crate::lib::Vec;
use crate::size_hint;
use crate::Itertools;

Expand Down
1 change: 1 addition & 0 deletions src/combinations.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fmt;
use crate::lib::Vec;

use super::lazy_buffer::LazyBuffer;

Expand Down
4 changes: 4 additions & 0 deletions src/combinations_with_replacement.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use std::fmt;

#[cfg(not(feature = "use_std"))]
use crate::lib::vec;
use crate::lib::Vec;

use super::lazy_buffer::LazyBuffer;

/// An iterator to iterate through all the `n`-length combinations in an iterator, with replacement.
Expand Down
6 changes: 2 additions & 4 deletions src/free.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
//! The benefit of free functions is that they accept any `IntoIterator` as
//! argument, so the resulting code may be easier to read.

#[cfg(feature = "use_std")]
use crate::VecIntoIter;
#[cfg(feature = "use_std")]
use std::fmt::Display;
use std::iter::{self, Zip};
#[cfg(feature = "use_std")]
type VecIntoIter<T> = ::std::vec::IntoIter<T>;

#[cfg(feature = "use_std")]
use crate::Itertools;
Expand All @@ -17,13 +17,11 @@ pub use crate::adaptors::{
merge,
put_back,
};
#[cfg(feature = "use_std")]
pub use crate::put_back_n_impl::put_back_n;
#[cfg(feature = "use_std")]
pub use crate::multipeek_impl::multipeek;
#[cfg(feature = "use_std")]
pub use crate::peek_nth::peek_nth;
#[cfg(feature = "use_std")]
pub use crate::kmerge_impl::kmerge;
pub use crate::zip_eq_impl::zip_eq;
pub use crate::merge_join::merge_join_by;
Expand Down
4 changes: 2 additions & 2 deletions src/group_map.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![cfg(feature = "use_std")]

use std::collections::HashMap;
use crate::lib::{HashMap, Vec};
use std::hash::Hash;
use std::iter::Iterator;

Expand All @@ -21,6 +20,7 @@ pub fn into_group_map<I, K, V>(iter: I) -> HashMap<K, Vec<V>>
lookup
}

#[cfg(feature = "use_std")]
pub fn into_group_map_by<I, K, V>(iter: I, f: impl Fn(&V) -> K) -> HashMap<K, Vec<V>>
where
I: Iterator<Item=V>,
Expand Down
2 changes: 1 addition & 1 deletion src/groupbylazy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::cell::{Cell, RefCell};
use std::vec;
use crate::lib::{vec, Vec};

/// A trait to unify FnMut for GroupBy with the chunk key in IntoChunks
trait KeyFunction<A> {
Expand Down
1 change: 1 addition & 0 deletions src/kmerge_impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::size_hint;
use crate::Itertools;
use crate::lib::Vec;

use std::mem::replace;
use std::fmt;
Expand Down
1 change: 1 addition & 0 deletions src/lazy_buffer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::ops::Index;
use crate::lib::Vec;

#[derive(Debug, Clone)]
pub struct LazyBuffer<I: Iterator> {
Expand Down
Loading