Skip to content

Commit

Permalink
Reverted formatting
Browse files Browse the repository at this point in the history
changes
  • Loading branch information
JoelMon committed Jul 10, 2022
1 parent e75a656 commit 9150cab
Showing 1 changed file with 43 additions and 53 deletions.
96 changes: 43 additions & 53 deletions src/free.rs
Expand Up @@ -10,24 +10,30 @@ use std::iter::{self, Zip};
type VecIntoIter<T> = alloc::vec::IntoIter<T>;

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

use crate::intersperse::{Intersperse, IntersperseWith};
use crate::Itertools;
use crate::intersperse::{Intersperse, IntersperseWith};

pub use crate::adaptors::{interleave, merge, put_back};
pub use crate::adaptors::{
interleave,
merge,
put_back,
};
#[cfg(feature = "use_alloc")]
pub use crate::kmerge_impl::kmerge;
pub use crate::merge_join::merge_join_by;
pub use crate::put_back_n_impl::put_back_n;
#[cfg(feature = "use_alloc")]
pub use crate::multipeek_impl::multipeek;
#[cfg(feature = "use_alloc")]
pub use crate::peek_nth::peek_nth;
#[cfg(feature = "use_alloc")]
pub use crate::put_back_n_impl::put_back_n;
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_alloc")]
pub use crate::rciter_impl::rciter;
pub use crate::zip_eq_impl::zip_eq;

/// Iterate `iterable` with a particular value inserted between each element.
///
Expand All @@ -39,9 +45,8 @@ pub use crate::zip_eq_impl::zip_eq;
/// itertools::assert_equal(intersperse((0..3), 8), vec![0, 8, 1, 8, 2]);
/// ```
pub fn intersperse<I>(iterable: I, element: I::Item) -> Intersperse<I::IntoIter>
where
I: IntoIterator,
<I as IntoIterator>::Item: Clone,
where I: IntoIterator,
<I as IntoIterator>::Item: Clone
{
Itertools::intersperse(iterable.into_iter(), element)
}
Expand All @@ -59,9 +64,8 @@ where
/// assert_eq!(i, 8);
/// ```
pub fn intersperse_with<I, F>(iterable: I, element: F) -> IntersperseWith<I::IntoIter, F>
where
I: IntoIterator,
F: FnMut() -> I::Item,
where I: IntoIterator,
F: FnMut() -> I::Item
{
Itertools::intersperse_with(iterable.into_iter(), element)
}
Expand All @@ -78,8 +82,7 @@ where
/// }
/// ```
pub fn enumerate<I>(iterable: I) -> iter::Enumerate<I::IntoIter>
where
I: IntoIterator,
where I: IntoIterator
{
iterable.into_iter().enumerate()
}
Expand All @@ -96,9 +99,8 @@ where
/// }
/// ```
pub fn rev<I>(iterable: I) -> iter::Rev<I::IntoIter>
where
I: IntoIterator,
I::IntoIter: DoubleEndedIterator,
where I: IntoIterator,
I::IntoIter: DoubleEndedIterator
{
iterable.into_iter().rev()
}
Expand All @@ -119,11 +121,9 @@ where
/// }
/// assert_eq!(result, vec![(1, 'a'),(2, 'b'),(3, 'c')]);
/// ```
///
pub fn zip<I, J>(i: I, j: J) -> Zip<I::IntoIter, J::IntoIter>
where
I: IntoIterator,
J: IntoIterator,
where I: IntoIterator,
J: IntoIterator
{
i.into_iter().zip(j)
}
Expand All @@ -139,13 +139,9 @@ where
/// /* loop body */
/// }
/// ```
pub fn chain<I, J>(
i: I,
j: J,
) -> iter::Chain<<I as IntoIterator>::IntoIter, <J as IntoIterator>::IntoIter>
where
I: IntoIterator,
J: IntoIterator<Item = I::Item>,
pub fn chain<I, J>(i: I, j: J) -> iter::Chain<<I as IntoIterator>::IntoIter, <J as IntoIterator>::IntoIter>
where I: IntoIterator,
J: IntoIterator<Item = I::Item>
{
i.into_iter().chain(j)
}
Expand All @@ -160,9 +156,8 @@ where
/// assert_eq!(cloned(b"abc").next(), Some(b'a'));
/// ```
pub fn cloned<'a, I, T: 'a>(iterable: I) -> iter::Cloned<I::IntoIter>
where
I: IntoIterator<Item = &'a T>,
T: Clone,
where I: IntoIterator<Item=&'a T>,
T: Clone,
{
iterable.into_iter().cloned()
}
Expand All @@ -177,9 +172,8 @@ where
/// assert_eq!(fold(&[1., 2., 3.], 0., |a, &b| f32::max(a, b)), 3.);
/// ```
pub fn fold<I, B, F>(iterable: I, init: B, f: F) -> B
where
I: IntoIterator,
F: FnMut(B, I::Item) -> B,
where I: IntoIterator,
F: FnMut(B, I::Item) -> B
{
iterable.into_iter().fold(init, f)
}
Expand All @@ -194,9 +188,8 @@ where
/// assert!(all(&[1, 2, 3], |elt| *elt > 0));
/// ```
pub fn all<I, F>(iterable: I, f: F) -> bool
where
I: IntoIterator,
F: FnMut(I::Item) -> bool,
where I: IntoIterator,
F: FnMut(I::Item) -> bool
{
iterable.into_iter().all(f)
}
Expand All @@ -211,9 +204,8 @@ where
/// assert!(any(&[0, -1, 2], |elt| *elt > 0));
/// ```
pub fn any<I, F>(iterable: I, f: F) -> bool
where
I: IntoIterator,
F: FnMut(I::Item) -> bool,
where I: IntoIterator,
F: FnMut(I::Item) -> bool
{
iterable.into_iter().any(f)
}
Expand All @@ -228,9 +220,8 @@ where
/// assert_eq!(max(0..10), Some(9));
/// ```
pub fn max<I>(iterable: I) -> Option<I::Item>
where
I: IntoIterator,
I::Item: Ord,
where I: IntoIterator,
I::Item: Ord
{
iterable.into_iter().max()
}
Expand All @@ -245,13 +236,13 @@ where
/// assert_eq!(min(0..10), Some(0));
/// ```
pub fn min<I>(iterable: I) -> Option<I::Item>
where
I: IntoIterator,
I::Item: Ord,
where I: IntoIterator,
I::Item: Ord
{
iterable.into_iter().min()
}


/// Combine all iterator elements into one String, separated by `sep`.
///
/// [`IntoIterator`] enabled version of [`Itertools::join`].
Expand All @@ -263,9 +254,8 @@ where
/// ```
#[cfg(feature = "use_alloc")]
pub fn join<I>(iterable: I, sep: &str) -> String
where
I: IntoIterator,
I::Item: Display,
where I: IntoIterator,
I::Item: Display
{
iterable.into_iter().join(sep)
}
Expand All @@ -282,9 +272,9 @@ where
/// ```
#[cfg(feature = "use_alloc")]
pub fn sorted<I>(iterable: I) -> VecIntoIter<I::Item>
where
I: IntoIterator,
I::Item: Ord,
where I: IntoIterator,
I::Item: Ord
{
iterable.into_iter().sorted()
}

0 comments on commit 9150cab

Please sign in to comment.