Skip to content

Commit

Permalink
use_std -> use_alloc, when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
jswrenn committed Sep 4, 2020
1 parent adcf70f commit 986d62b
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/adaptors/mod.rs
Expand Up @@ -11,7 +11,7 @@ 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")]
#[cfg(feature = "use_alloc")]
pub use self::multi_product::*;

use std::fmt;
Expand Down
4 changes: 3 additions & 1 deletion src/adaptors/multi_product.rs
@@ -1,8 +1,10 @@
#![cfg(feature = "use_std")]
#![cfg(feature = "use_alloc")]

use crate::size_hint;
use crate::Itertools;

use alloc::vec::Vec;

#[derive(Clone)]
/// An iterator adaptor that iterates over the cartesian product of
/// multiple iterators of type `I`.
Expand Down
1 change: 1 addition & 0 deletions src/combinations.rs
@@ -1,6 +1,7 @@
use std::fmt;

use super::lazy_buffer::LazyBuffer;
use alloc::vec::Vec;

/// An iterator to iterate through all the `k`-length combinations in an iterator.
///
Expand Down
3 changes: 2 additions & 1 deletion src/combinations_with_replacement.rs
@@ -1,3 +1,4 @@
use alloc::vec::Vec;
use std::fmt;

use super::lazy_buffer::LazyBuffer;
Expand Down Expand Up @@ -44,7 +45,7 @@ where
I: Iterator,
I::Item: Clone,
{
let indices: Vec<usize> = vec![0; k];
let indices: Vec<usize> = alloc::vec![0; k];
let pool: LazyBuffer<I> = LazyBuffer::new(iter);

CombinationsWithReplacement {
Expand Down
27 changes: 16 additions & 11 deletions src/free.rs
Expand Up @@ -3,31 +3,36 @@
//! 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")]
#[cfg(feature = "use_alloc")]
use std::fmt::Display;
use std::iter::{self, Zip};
#[cfg(feature = "use_std")]
type VecIntoIter<T> = ::std::vec::IntoIter<T>;
#[cfg(feature = "use_alloc")]
type VecIntoIter<T> = alloc::vec::IntoIter<T>;

#[cfg(feature = "use_std")]
#[cfg(feature = "use_alloc")]
use alloc::{
string::String,
};

#[cfg(feature = "use_alloc")]
use crate::Itertools;

pub use crate::adaptors::{
interleave,
merge,
put_back,
};
#[cfg(feature = "use_std")]
#[cfg(feature = "use_alloc")]
pub use crate::put_back_n_impl::put_back_n;
#[cfg(feature = "use_std")]
#[cfg(feature = "use_alloc")]
pub use crate::multipeek_impl::multipeek;
#[cfg(feature = "use_std")]
#[cfg(feature = "use_alloc")]
pub use crate::peek_nth::peek_nth;
#[cfg(feature = "use_std")]
#[cfg(feature = "use_alloc")]
pub use crate::kmerge_impl::kmerge;
pub use crate::zip_eq_impl::zip_eq;
pub use crate::merge_join::merge_join_by;
#[cfg(feature = "use_std")]
#[cfg(feature = "use_alloc")]
pub use crate::rciter_impl::rciter;

/// Iterate `iterable` with a running index.
Expand Down Expand Up @@ -208,7 +213,7 @@ pub fn min<I>(iterable: I) -> Option<I::Item>
///
/// assert_eq!(join(&[1, 2, 3], ", "), "1, 2, 3");
/// ```
#[cfg(feature = "use_std")]
#[cfg(feature = "use_alloc")]
pub fn join<I>(iterable: I, sep: &str) -> String
where I: IntoIterator,
I::Item: Display
Expand All @@ -228,7 +233,7 @@ pub fn join<I>(iterable: I, sep: &str) -> String
///
/// assert_equal(sorted("rust".chars()), "rstu".chars());
/// ```
#[cfg(feature = "use_std")]
#[cfg(feature = "use_alloc")]
pub fn sorted<I>(iterable: I) -> VecIntoIter<I::Item>
where I: IntoIterator,
I::Item: Ord
Expand Down
2 changes: 1 addition & 1 deletion src/groupbylazy.rs
@@ -1,5 +1,5 @@
use std::cell::{Cell, RefCell};
use std::vec;
use alloc::vec::{self, 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
@@ -1,6 +1,7 @@
use crate::size_hint;
use crate::Itertools;

use alloc::vec::Vec;
use std::mem::replace;
use std::fmt;

Expand Down
1 change: 1 addition & 0 deletions src/lazy_buffer.rs
@@ -1,4 +1,5 @@
use std::ops::Index;
use alloc::vec::Vec;

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

0 comments on commit 986d62b

Please sign in to comment.