Skip to content

Commit 273b382

Browse files
committed
removed formats for pullreq
1 parent a0f329a commit 273b382

File tree

1 file changed

+40
-43
lines changed

1 file changed

+40
-43
lines changed

src/lib.rs

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ use std::fmt;
6363
use std::hash::Hash;
6464
#[cfg(feature = "use_std")]
6565
use std::fmt::Write;
66-
6766
#[cfg(feature = "use_std")]
6867
type VecIntoIter<T> = ::std::vec::IntoIter<T>;
69-
68+
#[cfg(feature = "use_std")]
69+
type HashMapIntoIter<K, V> = ::std::collections::hash_map::IntoIter<K, V>;
7070
use std::iter::FromIterator;
7171

7272
#[macro_use]
@@ -151,7 +151,7 @@ pub use cons_tuples_impl::cons_tuples;
151151
pub use diff::diff_with;
152152
pub use diff::Diff;
153153
#[cfg(feature = "use_std")]
154-
pub use kmerge_impl::kmerge_by;
154+
pub use kmerge_impl::{kmerge_by};
155155
pub use minmax::MinMaxResult;
156156
pub use peeking_take_while::PeekingNext;
157157
pub use process_results_impl::process_results;
@@ -160,18 +160,13 @@ pub use repeatn::repeat_n;
160160
pub use sources::{repeat_call, unfold, iterate};
161161
pub use with_position::Position;
162162
pub use ziptuple::multizip;
163-
164163
mod adaptors;
165164
mod either_or_both;
166-
167165
pub use either_or_both::EitherOrBoth;
168-
169166
#[doc(hidden)]
170167
pub mod free;
171-
172168
#[doc(inline)]
173169
pub use free::*;
174-
175170
mod concat_impl;
176171
mod cons_tuples_impl;
177172
#[cfg(feature = "use_std")]
@@ -353,7 +348,7 @@ macro_rules! izip {
353348
/// method in the list.
354349
///
355350
/// [`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html
356-
pub trait Itertools: Iterator {
351+
pub trait Itertools : Iterator {
357352
// adaptors
358353

359354
/// Alternate elements from two iterators until both have run out.
@@ -369,7 +364,7 @@ pub trait Itertools: Iterator {
369364
/// itertools::assert_equal(it, vec![1, -1, 2, -2, 3, 4, 5, 6]);
370365
/// ```
371366
fn interleave<J>(self, other: J) -> Interleave<Self, J::IntoIter>
372-
where J: IntoIterator<Item=Self::Item>,
367+
where J: IntoIterator<Item = Self::Item>,
373368
Self: Sized
374369
{
375370
interleave(self, other)
@@ -387,7 +382,7 @@ pub trait Itertools: Iterator {
387382
/// itertools::assert_equal(it, vec![1, -1, 2, -2, 3]);
388383
/// ```
389384
fn interleave_shortest<J>(self, other: J) -> InterleaveShortest<Self, J::IntoIter>
390-
where J: IntoIterator<Item=Self::Item>,
385+
where J: IntoIterator<Item = Self::Item>,
391386
Self: Sized
392387
{
393388
adaptors::interleave_shortest(self, other.into_iter())
@@ -599,7 +594,7 @@ pub trait Itertools: Iterator {
599594
/// itertools::assert_equal(it, vec![(1, 2, 3), (2, 3, 4)]);
600595
/// ```
601596
fn tuple_windows<T>(self) -> TupleWindows<Self, T>
602-
where Self: Sized + Iterator<Item=T::Item>,
597+
where Self: Sized + Iterator<Item = T::Item>,
603598
T: traits::HomogeneousTuple,
604599
T::Item: Clone
605600
{
@@ -638,7 +633,7 @@ pub trait Itertools: Iterator {
638633
///
639634
/// See also [`Tuples::into_buffer`](structs/struct.Tuples.html#method.into_buffer).
640635
fn tuples<T>(self) -> Tuples<Self, T>
641-
where Self: Sized + Iterator<Item=T::Item>,
636+
where Self: Sized + Iterator<Item = T::Item>,
642637
T: traits::HomogeneousTuple
643638
{
644639
tuple_impl::tuples(self)
@@ -719,7 +714,7 @@ pub trait Itertools: Iterator {
719714
/// itertools::assert_equal(it, vec![Ok(42), Err(false), Ok(12)]);
720715
/// ```
721716
fn map_results<F, T, U, E>(self, f: F) -> MapResults<Self, F>
722-
where Self: Iterator<Item=Result<T, E>> + Sized,
717+
where Self: Iterator<Item = Result<T, E>> + Sized,
723718
F: FnMut(T) -> U,
724719
{
725720
adaptors::map_results(self, f)
@@ -742,7 +737,7 @@ pub trait Itertools: Iterator {
742737
fn merge<J>(self, other: J) -> Merge<Self, J::IntoIter>
743738
where Self: Sized,
744739
Self::Item: PartialOrd,
745-
J: IntoIterator<Item=Self::Item>
740+
J: IntoIterator<Item = Self::Item>
746741
{
747742
merge(self, other)
748743
}
@@ -765,7 +760,7 @@ pub trait Itertools: Iterator {
765760
766761
fn merge_by<J, F>(self, other: J, is_first: F) -> MergeBy<Self, J::IntoIter, F>
767762
where Self: Sized,
768-
J: IntoIterator<Item=Self::Item>,
763+
J: IntoIterator<Item = Self::Item>,
769764
F: FnMut(&Self::Item, &Self::Item) -> bool
770765
{
771766
adaptors::merge_by_new(self, other.into_iter(), is_first)
@@ -954,7 +949,7 @@ pub trait Itertools: Iterator {
954949
fn coalesce<F>(self, f: F) -> Coalesce<Self, F>
955950
where Self: Sized,
956951
F: FnMut(Self::Item, Self::Item)
957-
-> Result<Self::Item, (Self::Item, Self::Item)>
952+
-> Result<Self::Item, (Self::Item, Self::Item)>
958953
{
959954
adaptors::coalesce(self, f)
960955
}
@@ -1106,7 +1101,7 @@ pub trait Itertools: Iterator {
11061101
///
11071102
/// ```
11081103
fn while_some<A>(self) -> WhileSome<Self>
1109-
where Self: Sized + Iterator<Item=Option<A>>
1104+
where Self: Sized + Iterator<Item = Option<A>>
11101105
{
11111106
adaptors::while_some(self)
11121107
}
@@ -1210,9 +1205,9 @@ pub trait Itertools: Iterator {
12101205
/// ```
12111206
#[cfg(feature = "use_std")]
12121207
fn combinations_with_replacement(self, k: usize) -> CombinationsWithReplacement<Self>
1213-
where
1214-
Self: Sized,
1215-
Self::Item: Clone,
1208+
where
1209+
Self: Sized,
1210+
Self::Item: Clone,
12161211
{
12171212
combinations_with_replacement::combinations_with_replacement(self, k)
12181213
}
@@ -1363,7 +1358,7 @@ pub trait Itertools: Iterator {
13631358
/// assert_eq!(Some((1, 2)), iter.next_tuple());
13641359
/// ```
13651360
fn next_tuple<T>(&mut self) -> Option<T>
1366-
where Self: Sized + Iterator<Item=T::Item>,
1361+
where Self: Sized + Iterator<Item = T::Item>,
13671362
T: traits::HomogeneousTuple
13681363
{
13691364
T::collect_from_iter_no_buf(self)
@@ -1388,7 +1383,7 @@ pub trait Itertools: Iterator {
13881383
/// }
13891384
/// ```
13901385
fn collect_tuple<T>(mut self) -> Option<T>
1391-
where Self: Sized + Iterator<Item=T::Item>,
1386+
where Self: Sized + Iterator<Item = T::Item>,
13921387
T: traits::HomogeneousTuple
13931388
{
13941389
match self.next_tuple() {
@@ -1575,9 +1570,9 @@ pub trait Itertools: Iterator {
15751570
/// ```
15761571
#[cfg(feature = "use_std")]
15771572
fn try_collect<T, U, E>(self) -> Result<U, E>
1578-
where
1579-
Self: Sized + Iterator<Item=Result<T, E>>,
1580-
Result<U, E>: FromIterator<Result<T, E>>,
1573+
where
1574+
Self: Sized + Iterator<Item = Result<T, E>>,
1575+
Result<U, E>: FromIterator<Result<T, E>>,
15811576
{
15821577
self.collect()
15831578
}
@@ -1599,8 +1594,8 @@ pub trait Itertools: Iterator {
15991594
/// ```
16001595
#[inline]
16011596
fn set_from<'a, A: 'a, J>(&mut self, from: J) -> usize
1602-
where Self: Iterator<Item=&'a mut A>,
1603-
J: IntoIterator<Item=A>
1597+
where Self: Iterator<Item = &'a mut A>,
1598+
J: IntoIterator<Item = A>
16041599
{
16051600
let mut count = 0;
16061601
for elt in from {
@@ -1746,7 +1741,7 @@ pub trait Itertools: Iterator {
17461741
/// );
17471742
/// ```
17481743
fn fold_results<A, E, B, F>(&mut self, mut start: B, mut f: F) -> Result<B, E>
1749-
where Self: Iterator<Item=Result<A, E>>,
1744+
where Self: Iterator<Item = Result<A, E>>,
17501745
F: FnMut(B, A) -> B
17511746
{
17521747
for elt in self {
@@ -1778,7 +1773,7 @@ pub trait Itertools: Iterator {
17781773
/// assert_eq!(more_values.next().unwrap(), Some(0));
17791774
/// ```
17801775
fn fold_options<A, B, F>(&mut self, mut start: B, mut f: F) -> Option<B>
1781-
where Self: Iterator<Item=Option<A>>,
1776+
where Self: Iterator<Item = Option<A>>,
17821777
F: FnMut(B, A) -> B
17831778
{
17841779
for elt in self {
@@ -1865,23 +1860,25 @@ pub trait Itertools: Iterator {
18651860

18661861
fn inner0<T, II, FF>(it: &mut II, f: &mut FF) -> State<T>
18671862
where
1868-
II: Iterator<Item=T>,
1863+
II: Iterator<Item = T>,
18691864
FF: FnMut(T, T) -> T
18701865
{
18711866
// This function could be replaced with `it.next().ok_or(None)`,
18721867
// but half the useful tree_fold1 work is combining adjacent items,
18731868
// so put that in a form that LLVM is more likely to optimize well.
18741869

18751870
let a =
1876-
if let Some(v) = it.next() { v } else { return Err(None); };
1871+
if let Some(v) = it.next() { v }
1872+
else { return Err(None) };
18771873
let b =
1878-
if let Some(v) = it.next() { v } else { return Err(Some(a)); };
1874+
if let Some(v) = it.next() { v }
1875+
else { return Err(Some(a)) };
18791876
Ok(f(a, b))
18801877
}
18811878

18821879
fn inner<T, II, FF>(stop: usize, it: &mut II, f: &mut FF) -> State<T>
18831880
where
1884-
II: Iterator<Item=T>,
1881+
II: Iterator<Item = T>,
18851882
FF: FnMut(T, T) -> T
18861883
{
18871884
let mut x = inner0(it, f)?;
@@ -2193,8 +2190,9 @@ pub trait Itertools: Iterator {
21932190
/// use std::collections::HashMap;
21942191
///
21952192
/// let data = vec![(0, 10), (2, 12), (3, 13), (0, 20), (3, 33), (2, 42)];
2196-
/// let lookup: HashMap<u32,Vec<(u32, u32)>> =
2197-
/// data.clone().into_iter().into_group_map_by(|a| a.0);
2193+
/// let lookup: HashMap<u32,Vec<(u32, u32)>> = data.clone().into_iter().into_group_map_by(|a|
2194+
/// a.0)
2195+
/// .collect();
21982196
///
21992197
/// assert_eq!(lookup[&0], vec![(0,10),(0,20)]);
22002198
/// assert_eq!(lookup.get(&1), None);
@@ -2204,12 +2202,11 @@ pub trait Itertools: Iterator {
22042202
/// assert_eq!(
22052203
/// data.into_iter()
22062204
/// .into_group_map_by(|x| x.0)
2207-
/// .into_iter()
22082205
/// .map(|(key, values)| (key, values.into_iter().fold(0,|acc, (_,v)| acc + v )))
22092206
/// .collect::<HashMap<u32,u32>>()[&0], 30)
22102207
/// ```
22112208
#[cfg(feature = "use_std")]
2212-
fn into_group_map_by<K, V, F>(self, f: F) -> HashMap<K, Vec<V>>
2209+
fn into_group_map_by<K, V, F>(self, f: F) -> HashMapIntoIter<K, Vec<V>>
22132210
where
22142211
Self: Iterator<Item=V> + Sized,
22152212
K: Hash + Eq,
@@ -2290,7 +2287,7 @@ pub trait Itertools: Iterator {
22902287
minmax::minmax_impl(
22912288
self,
22922289
|_| (),
2293-
|x, y, _, _| Ordering::Less == compare(x, y),
2290+
|x, y, _, _| Ordering::Less == compare(x, y)
22942291
)
22952292
}
22962293

@@ -2312,8 +2309,8 @@ pub trait Itertools: Iterator {
23122309
/// assert!((0..10).filter(|&_| false).exactly_one().unwrap_err().eq(0..0));
23132310
/// ```
23142311
fn exactly_one(mut self) -> Result<Self::Item, ExactlyOneError<Self>>
2315-
where
2316-
Self: Sized,
2312+
where
2313+
Self: Sized,
23172314
{
23182315
match self.next() {
23192316
Some(first) => {
@@ -2331,7 +2328,7 @@ pub trait Itertools: Iterator {
23312328
}
23322329
}
23332330

2334-
impl<T: ?Sized> Itertools for T where T: Iterator {}
2331+
impl<T: ?Sized> Itertools for T where T: Iterator { }
23352332

23362333
/// Return `true` if both iterables produce equal sequences
23372334
/// (elements pairwise equal and sequences of the same length),
@@ -2415,7 +2412,7 @@ pub fn assert_equal<I, J>(a: I, b: J)
24152412
/// assert_eq!(split_index, 3);
24162413
/// ```
24172414
pub fn partition<'a, A: 'a, I, F>(iter: I, mut pred: F) -> usize
2418-
where I: IntoIterator<Item=&'a mut A>,
2415+
where I: IntoIterator<Item = &'a mut A>,
24192416
I::IntoIter: DoubleEndedIterator,
24202417
F: FnMut(&A) -> bool
24212418
{

0 commit comments

Comments
 (0)