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 } ;
52
63/// A wrapper type around a key function.
74///
6158/// [`Iterator::dedup`]: Iterator::dedup
6259#[ unstable( feature = "iter_dedup" , reason = "recently added" , issue = "83748" ) ]
6360#[ derive( Debug , Clone , Copy ) ]
61+ #[ non_exhaustive]
6462pub struct ByPartialEq ;
6563
6664impl ByPartialEq {
@@ -131,9 +129,9 @@ where
131129 self . last = Some ( self . inner . next ( ) )
132130 }
133131
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 ( ) } ;
135134 let last_item = last. as_ref ( ) ?;
136-
137135 let mut next = loop {
138136 let curr = self . inner . next ( ) ;
139137 if let Some ( curr_item) = & curr {
@@ -145,7 +143,7 @@ where
145143 }
146144 } ;
147145
148- swap ( last, & mut next) ;
146+ crate :: mem :: swap ( last, & mut next) ;
149147 next
150148 }
151149
You can’t perform that action at this time.
0 commit comments