File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
library/core/src/iter/adapters Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change 1
- use crate :: {
2
- iter:: { InPlaceIterable , SourceIter } ,
3
- mem:: swap,
4
- } ;
1
+ use crate :: iter:: { InPlaceIterable , SourceIter } ;
5
2
6
3
/// A wrapper type around a key function.
7
4
///
61
58
/// [`Iterator::dedup`]: Iterator::dedup
62
59
#[ unstable( feature = "iter_dedup" , reason = "recently added" , issue = "83748" ) ]
63
60
#[ derive( Debug , Clone , Copy ) ]
61
+ #[ non_exhaustive]
64
62
pub struct ByPartialEq ;
65
63
66
64
impl ByPartialEq {
@@ -131,9 +129,9 @@ where
131
129
self . last = Some ( self . inner . next ( ) )
132
130
}
133
131
134
- let last = self . last . as_mut ( ) . unwrap ( ) ;
132
+ // Safety: the above if statement ensures that `self.last` is always `Some`
133
+ let last = unsafe { self . last . as_mut ( ) . unwrap_unchecked ( ) } ;
135
134
let last_item = last. as_ref ( ) ?;
136
-
137
135
let mut next = loop {
138
136
let curr = self . inner . next ( ) ;
139
137
if let Some ( curr_item) = & curr {
@@ -145,7 +143,7 @@ where
145
143
}
146
144
} ;
147
145
148
- swap ( last, & mut next) ;
146
+ crate :: mem :: swap ( last, & mut next) ;
149
147
next
150
148
}
151
149
You can’t perform that action at this time.
0 commit comments