@@ -289,27 +289,27 @@ unsafe impl<T, A: Allocator> TrustedRandomAccess for IntoIter<T, A>
289
289
where
290
290
T : NonDrop ,
291
291
{
292
- fn cleanup ( & mut self , num : usize , forward : bool ) {
293
- if forward {
294
- if mem:: size_of :: < T > ( ) == 0 {
295
- // SAFETY: due to unchecked casts of unsigned amounts to signed offsets the wraparound
296
- // effectively results in unsigned pointers representing positions 0..usize::MAX,
297
- // which is valid for ZSTs.
298
- self . ptr = unsafe { arith_offset ( self . ptr as * const i8 , num as isize ) as * mut T }
299
- } else {
300
- // SAFETY: the caller must guarantee that `num` is in bounds
301
- self . ptr = unsafe { self . ptr . add ( num) } ;
302
- }
292
+ fn cleanup_front ( & mut self , num : usize ) {
293
+ if mem:: size_of :: < T > ( ) == 0 {
294
+ // SAFETY: due to unchecked casts of unsigned amounts to signed offsets the wraparound
295
+ // effectively results in unsigned pointers representing positions 0..usize::MAX,
296
+ // which is valid for ZSTs.
297
+ self . ptr = unsafe { arith_offset ( self . ptr as * const i8 , num as isize ) as * mut T }
303
298
} else {
304
- if mem:: size_of :: < T > ( ) == 0 {
305
- // SAFETY: same as above
306
- self . end = unsafe {
307
- arith_offset ( self . end as * const i8 , num. wrapping_neg ( ) as isize ) as * mut T
308
- }
309
- } else {
310
- // SAFETY: same as above
311
- self . end = unsafe { self . end . offset ( num. wrapping_neg ( ) as isize ) } ;
299
+ // SAFETY: the caller must guarantee that `num` is in bounds
300
+ self . ptr = unsafe { self . ptr . add ( num) } ;
301
+ }
302
+ }
303
+
304
+ fn cleanup_back ( & mut self , num : usize ) {
305
+ if mem:: size_of :: < T > ( ) == 0 {
306
+ // SAFETY: same as above
307
+ self . end = unsafe {
308
+ arith_offset ( self . end as * const i8 , num. wrapping_neg ( ) as isize ) as * mut T
312
309
}
310
+ } else {
311
+ // SAFETY: same as above
312
+ self . end = unsafe { self . end . offset ( num. wrapping_neg ( ) as isize ) } ;
313
313
}
314
314
}
315
315
}
0 commit comments