File tree 1 file changed +17
-5
lines changed
1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -2956,11 +2956,23 @@ impl<T> Iterator for IntoIter<T> {
2956
2956
if mem:: size_of :: < T > ( ) == 0 { mem:: zeroed ( ) } else { ptr:: read ( self . ptr . add ( i) ) }
2957
2957
}
2958
2958
#[ inline]
2959
- fn last ( self ) -> Option < Self :: Item >
2960
- where
2961
- Self : Sized ,
2962
- {
2963
- if self . ptr == self . end { None } else { unsafe { Some ( ptr:: read ( self . end . offset ( -1 ) ) ) } }
2959
+ fn last ( mut self ) -> Option < T > {
2960
+ unsafe {
2961
+ if self . ptr as * const _ == self . end {
2962
+ None
2963
+ } else {
2964
+ if mem:: size_of :: < T > ( ) == 0 {
2965
+ // Immediately marches to end of the iterator.
2966
+ self . ptr = self . end ;
2967
+ // Make up a value of this ZST.
2968
+ Some ( mem:: zeroed ( ) )
2969
+ } else {
2970
+ // Immediately marches to end of the iterator.
2971
+ self . ptr = self . end ;
2972
+ Some ( ptr:: read ( self . ptr . offset ( -1 ) ) )
2973
+ }
2974
+ }
2975
+ }
2964
2976
}
2965
2977
}
2966
2978
You can’t perform that action at this time.
0 commit comments