@@ -63,10 +63,10 @@ use std::fmt;
63
63
use std:: hash:: Hash ;
64
64
#[ cfg( feature = "use_std" ) ]
65
65
use std:: fmt:: Write ;
66
-
67
66
#[ cfg( feature = "use_std" ) ]
68
67
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 > ;
70
70
use std:: iter:: FromIterator ;
71
71
72
72
#[ macro_use]
@@ -151,7 +151,7 @@ pub use cons_tuples_impl::cons_tuples;
151
151
pub use diff:: diff_with;
152
152
pub use diff:: Diff ;
153
153
#[ cfg( feature = "use_std" ) ]
154
- pub use kmerge_impl:: kmerge_by;
154
+ pub use kmerge_impl:: { kmerge_by} ;
155
155
pub use minmax:: MinMaxResult ;
156
156
pub use peeking_take_while:: PeekingNext ;
157
157
pub use process_results_impl:: process_results;
@@ -160,18 +160,13 @@ pub use repeatn::repeat_n;
160
160
pub use sources:: { repeat_call, unfold, iterate} ;
161
161
pub use with_position:: Position ;
162
162
pub use ziptuple:: multizip;
163
-
164
163
mod adaptors;
165
164
mod either_or_both;
166
-
167
165
pub use either_or_both:: EitherOrBoth ;
168
-
169
166
#[ doc( hidden) ]
170
167
pub mod free;
171
-
172
168
#[ doc( inline) ]
173
169
pub use free:: * ;
174
-
175
170
mod concat_impl;
176
171
mod cons_tuples_impl;
177
172
#[ cfg( feature = "use_std" ) ]
@@ -353,7 +348,7 @@ macro_rules! izip {
353
348
/// method in the list.
354
349
///
355
350
/// [`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html
356
- pub trait Itertools : Iterator {
351
+ pub trait Itertools : Iterator {
357
352
// adaptors
358
353
359
354
/// Alternate elements from two iterators until both have run out.
@@ -369,7 +364,7 @@ pub trait Itertools: Iterator {
369
364
/// itertools::assert_equal(it, vec![1, -1, 2, -2, 3, 4, 5, 6]);
370
365
/// ```
371
366
fn interleave < J > ( self , other : J ) -> Interleave < Self , J :: IntoIter >
372
- where J : IntoIterator < Item = Self :: Item > ,
367
+ where J : IntoIterator < Item = Self :: Item > ,
373
368
Self : Sized
374
369
{
375
370
interleave ( self , other)
@@ -387,7 +382,7 @@ pub trait Itertools: Iterator {
387
382
/// itertools::assert_equal(it, vec![1, -1, 2, -2, 3]);
388
383
/// ```
389
384
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 > ,
391
386
Self : Sized
392
387
{
393
388
adaptors:: interleave_shortest ( self , other. into_iter ( ) )
@@ -599,7 +594,7 @@ pub trait Itertools: Iterator {
599
594
/// itertools::assert_equal(it, vec![(1, 2, 3), (2, 3, 4)]);
600
595
/// ```
601
596
fn tuple_windows < T > ( self ) -> TupleWindows < Self , T >
602
- where Self : Sized + Iterator < Item = T :: Item > ,
597
+ where Self : Sized + Iterator < Item = T :: Item > ,
603
598
T : traits:: HomogeneousTuple ,
604
599
T :: Item : Clone
605
600
{
@@ -638,7 +633,7 @@ pub trait Itertools: Iterator {
638
633
///
639
634
/// See also [`Tuples::into_buffer`](structs/struct.Tuples.html#method.into_buffer).
640
635
fn tuples < T > ( self ) -> Tuples < Self , T >
641
- where Self : Sized + Iterator < Item = T :: Item > ,
636
+ where Self : Sized + Iterator < Item = T :: Item > ,
642
637
T : traits:: HomogeneousTuple
643
638
{
644
639
tuple_impl:: tuples ( self )
@@ -719,7 +714,7 @@ pub trait Itertools: Iterator {
719
714
/// itertools::assert_equal(it, vec![Ok(42), Err(false), Ok(12)]);
720
715
/// ```
721
716
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 ,
723
718
F : FnMut ( T ) -> U ,
724
719
{
725
720
adaptors:: map_results ( self , f)
@@ -742,7 +737,7 @@ pub trait Itertools: Iterator {
742
737
fn merge < J > ( self , other : J ) -> Merge < Self , J :: IntoIter >
743
738
where Self : Sized ,
744
739
Self :: Item : PartialOrd ,
745
- J : IntoIterator < Item = Self :: Item >
740
+ J : IntoIterator < Item = Self :: Item >
746
741
{
747
742
merge ( self , other)
748
743
}
@@ -765,7 +760,7 @@ pub trait Itertools: Iterator {
765
760
766
761
fn merge_by < J , F > ( self , other : J , is_first : F ) -> MergeBy < Self , J :: IntoIter , F >
767
762
where Self : Sized ,
768
- J : IntoIterator < Item = Self :: Item > ,
763
+ J : IntoIterator < Item = Self :: Item > ,
769
764
F : FnMut ( & Self :: Item , & Self :: Item ) -> bool
770
765
{
771
766
adaptors:: merge_by_new ( self , other. into_iter ( ) , is_first)
@@ -954,7 +949,7 @@ pub trait Itertools: Iterator {
954
949
fn coalesce < F > ( self , f : F ) -> Coalesce < Self , F >
955
950
where Self : Sized ,
956
951
F : FnMut ( Self :: Item , Self :: Item )
957
- -> Result < Self :: Item , ( Self :: Item , Self :: Item ) >
952
+ -> Result < Self :: Item , ( Self :: Item , Self :: Item ) >
958
953
{
959
954
adaptors:: coalesce ( self , f)
960
955
}
@@ -1106,7 +1101,7 @@ pub trait Itertools: Iterator {
1106
1101
///
1107
1102
/// ```
1108
1103
fn while_some < A > ( self ) -> WhileSome < Self >
1109
- where Self : Sized + Iterator < Item = Option < A > >
1104
+ where Self : Sized + Iterator < Item = Option < A > >
1110
1105
{
1111
1106
adaptors:: while_some ( self )
1112
1107
}
@@ -1210,9 +1205,9 @@ pub trait Itertools: Iterator {
1210
1205
/// ```
1211
1206
#[ cfg( feature = "use_std" ) ]
1212
1207
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 ,
1216
1211
{
1217
1212
combinations_with_replacement:: combinations_with_replacement ( self , k)
1218
1213
}
@@ -1363,7 +1358,7 @@ pub trait Itertools: Iterator {
1363
1358
/// assert_eq!(Some((1, 2)), iter.next_tuple());
1364
1359
/// ```
1365
1360
fn next_tuple < T > ( & mut self ) -> Option < T >
1366
- where Self : Sized + Iterator < Item = T :: Item > ,
1361
+ where Self : Sized + Iterator < Item = T :: Item > ,
1367
1362
T : traits:: HomogeneousTuple
1368
1363
{
1369
1364
T :: collect_from_iter_no_buf ( self )
@@ -1388,7 +1383,7 @@ pub trait Itertools: Iterator {
1388
1383
/// }
1389
1384
/// ```
1390
1385
fn collect_tuple < T > ( mut self ) -> Option < T >
1391
- where Self : Sized + Iterator < Item = T :: Item > ,
1386
+ where Self : Sized + Iterator < Item = T :: Item > ,
1392
1387
T : traits:: HomogeneousTuple
1393
1388
{
1394
1389
match self . next_tuple ( ) {
@@ -1575,9 +1570,9 @@ pub trait Itertools: Iterator {
1575
1570
/// ```
1576
1571
#[ cfg( feature = "use_std" ) ]
1577
1572
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 > > ,
1581
1576
{
1582
1577
self . collect ( )
1583
1578
}
@@ -1599,8 +1594,8 @@ pub trait Itertools: Iterator {
1599
1594
/// ```
1600
1595
#[ inline]
1601
1596
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 >
1604
1599
{
1605
1600
let mut count = 0 ;
1606
1601
for elt in from {
@@ -1746,7 +1741,7 @@ pub trait Itertools: Iterator {
1746
1741
/// );
1747
1742
/// ```
1748
1743
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 > > ,
1750
1745
F : FnMut ( B , A ) -> B
1751
1746
{
1752
1747
for elt in self {
@@ -1778,7 +1773,7 @@ pub trait Itertools: Iterator {
1778
1773
/// assert_eq!(more_values.next().unwrap(), Some(0));
1779
1774
/// ```
1780
1775
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 > > ,
1782
1777
F : FnMut ( B , A ) -> B
1783
1778
{
1784
1779
for elt in self {
@@ -1865,23 +1860,25 @@ pub trait Itertools: Iterator {
1865
1860
1866
1861
fn inner0 < T , II , FF > ( it : & mut II , f : & mut FF ) -> State < T >
1867
1862
where
1868
- II : Iterator < Item = T > ,
1863
+ II : Iterator < Item = T > ,
1869
1864
FF : FnMut ( T , T ) -> T
1870
1865
{
1871
1866
// This function could be replaced with `it.next().ok_or(None)`,
1872
1867
// but half the useful tree_fold1 work is combining adjacent items,
1873
1868
// so put that in a form that LLVM is more likely to optimize well.
1874
1869
1875
1870
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 ) } ;
1877
1873
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) ) } ;
1879
1876
Ok ( f ( a, b) )
1880
1877
}
1881
1878
1882
1879
fn inner < T , II , FF > ( stop : usize , it : & mut II , f : & mut FF ) -> State < T >
1883
1880
where
1884
- II : Iterator < Item = T > ,
1881
+ II : Iterator < Item = T > ,
1885
1882
FF : FnMut ( T , T ) -> T
1886
1883
{
1887
1884
let mut x = inner0 ( it, f) ?;
@@ -2193,8 +2190,9 @@ pub trait Itertools: Iterator {
2193
2190
/// use std::collections::HashMap;
2194
2191
///
2195
2192
/// 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();
2198
2196
///
2199
2197
/// assert_eq!(lookup[&0], vec![(0,10),(0,20)]);
2200
2198
/// assert_eq!(lookup.get(&1), None);
@@ -2204,12 +2202,11 @@ pub trait Itertools: Iterator {
2204
2202
/// assert_eq!(
2205
2203
/// data.into_iter()
2206
2204
/// .into_group_map_by(|x| x.0)
2207
- /// .into_iter()
2208
2205
/// .map(|(key, values)| (key, values.into_iter().fold(0,|acc, (_,v)| acc + v )))
2209
2206
/// .collect::<HashMap<u32,u32>>()[&0], 30)
2210
2207
/// ```
2211
2208
#[ 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 > >
2213
2210
where
2214
2211
Self : Iterator < Item =V > + Sized ,
2215
2212
K : Hash + Eq ,
@@ -2290,7 +2287,7 @@ pub trait Itertools: Iterator {
2290
2287
minmax:: minmax_impl (
2291
2288
self ,
2292
2289
|_| ( ) ,
2293
- |x, y, _, _| Ordering :: Less == compare ( x, y) ,
2290
+ |x, y, _, _| Ordering :: Less == compare ( x, y)
2294
2291
)
2295
2292
}
2296
2293
@@ -2312,8 +2309,8 @@ pub trait Itertools: Iterator {
2312
2309
/// assert!((0..10).filter(|&_| false).exactly_one().unwrap_err().eq(0..0));
2313
2310
/// ```
2314
2311
fn exactly_one ( mut self ) -> Result < Self :: Item , ExactlyOneError < Self > >
2315
- where
2316
- Self : Sized ,
2312
+ where
2313
+ Self : Sized ,
2317
2314
{
2318
2315
match self . next ( ) {
2319
2316
Some ( first) => {
@@ -2331,7 +2328,7 @@ pub trait Itertools: Iterator {
2331
2328
}
2332
2329
}
2333
2330
2334
- impl < T : ?Sized > Itertools for T where T : Iterator { }
2331
+ impl < T : ?Sized > Itertools for T where T : Iterator { }
2335
2332
2336
2333
/// Return `true` if both iterables produce equal sequences
2337
2334
/// (elements pairwise equal and sequences of the same length),
@@ -2415,7 +2412,7 @@ pub fn assert_equal<I, J>(a: I, b: J)
2415
2412
/// assert_eq!(split_index, 3);
2416
2413
/// ```
2417
2414
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 > ,
2419
2416
I :: IntoIter : DoubleEndedIterator ,
2420
2417
F : FnMut ( & A ) -> bool
2421
2418
{
0 commit comments