File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: PutBack ;
2
2
#[ cfg( feature = "use_alloc" ) ]
3
3
use crate :: PutBackN ;
4
+ use crate :: RepeatN ;
4
5
use std:: iter:: Peekable ;
5
6
6
7
/// An iterator that allows peeking at an element before deciding to accept it.
91
92
}
92
93
}
93
94
95
+ impl < T : Clone > PeekingNext for RepeatN < T > {
96
+ fn peeking_next < F > ( & mut self , accept : F ) -> Option < Self :: Item >
97
+ where
98
+ F : FnOnce ( & Self :: Item ) -> bool ,
99
+ {
100
+ let r = self . elt . as_ref ( ) ?;
101
+ if !accept ( r) {
102
+ return None ;
103
+ }
104
+ self . next ( )
105
+ }
106
+ }
107
+
94
108
/// An iterator adaptor that takes items while a closure returns `true`.
95
109
///
96
110
/// See [`.peeking_take_while()`](crate::Itertools::peeking_take_while)
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use std::iter::FusedIterator;
6
6
#[ must_use = "iterators are lazy and do nothing unless consumed" ]
7
7
#[ derive( Clone , Debug ) ]
8
8
pub struct RepeatN < A > {
9
- elt : Option < A > ,
9
+ pub ( crate ) elt : Option < A > ,
10
10
n : usize ,
11
11
}
12
12
You can’t perform that action at this time.
0 commit comments