File tree Expand file tree Collapse file tree 1 file changed +4
-19
lines changed
library/core/src/iter/adapters Expand file tree Collapse file tree 1 file changed +4
-19
lines changed Original file line number Diff line number Diff line change @@ -125,26 +125,11 @@ where
125
125
126
126
#[ inline]
127
127
fn next ( & mut self ) -> Option < Self :: Item > {
128
- if self . last . is_none ( ) {
129
- self . last = Some ( self . inner . next ( ) )
130
- }
131
-
132
- // Safety: the above if statement ensures that `self.last` is always `Some`
133
- let last = unsafe { self . last . as_mut ( ) . unwrap_unchecked ( ) } ;
128
+ let Self { inner, last, same_bucket } = self ;
129
+ let last = last. get_or_insert_with ( || inner. next ( ) ) ;
134
130
let last_item = last. as_ref ( ) ?;
135
- let mut next = loop {
136
- let curr = self . inner . next ( ) ;
137
- if let Some ( curr_item) = & curr {
138
- if !( self . same_bucket ) ( last_item, curr_item) {
139
- break curr;
140
- }
141
- } else {
142
- break None ;
143
- }
144
- } ;
145
-
146
- crate :: mem:: swap ( last, & mut next) ;
147
- next
131
+ let next = inner. find ( |next_item| !( same_bucket) ( last_item, next_item) ) ;
132
+ crate :: mem:: replace ( last, next)
148
133
}
149
134
150
135
#[ inline]
You can’t perform that action at this time.
0 commit comments