@@ -328,7 +328,7 @@ impl<T> [T] {
328
328
} else {
329
329
// SAFETY: We explicitly check for the correct number of elements,
330
330
// and do not let the reference outlive the slice.
331
- Some ( unsafe { & * ( self . as_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } )
331
+ Some ( unsafe { & * ( self . as_ptr ( ) . cast_array ( ) ) } )
332
332
}
333
333
}
334
334
@@ -359,7 +359,7 @@ impl<T> [T] {
359
359
// SAFETY: We explicitly check for the correct number of elements,
360
360
// do not let the reference outlive the slice,
361
361
// and require exclusive access to the entire slice to mutate the chunk.
362
- Some ( unsafe { & mut * ( self . as_mut_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } )
362
+ Some ( unsafe { & mut * ( self . as_mut_ptr ( ) . cast_array ( ) ) } )
363
363
}
364
364
}
365
365
@@ -387,7 +387,7 @@ impl<T> [T] {
387
387
388
388
// SAFETY: We explicitly check for the correct number of elements,
389
389
// and do not let the references outlive the slice.
390
- Some ( ( unsafe { & * ( first. as_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } , tail) )
390
+ Some ( ( unsafe { & * ( first. as_ptr ( ) . cast_array ( ) ) } , tail) )
391
391
}
392
392
393
393
/// Returns a mutable array reference to the first `N` items in the slice and the remaining
@@ -420,7 +420,7 @@ impl<T> [T] {
420
420
// SAFETY: We explicitly check for the correct number of elements,
421
421
// do not let the reference outlive the slice,
422
422
// and enforce exclusive mutability of the chunk by the split.
423
- Some ( ( unsafe { & mut * ( first. as_mut_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } , tail) )
423
+ Some ( ( unsafe { & mut * ( first. as_mut_ptr ( ) . cast_array ( ) ) } , tail) )
424
424
}
425
425
426
426
/// Returns an array reference to the last `N` items in the slice and the remaining slice.
@@ -448,7 +448,7 @@ impl<T> [T] {
448
448
449
449
// SAFETY: We explicitly check for the correct number of elements,
450
450
// and do not let the references outlive the slice.
451
- Some ( ( init, unsafe { & * ( last. as_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } ) )
451
+ Some ( ( init, unsafe { & * ( last. as_ptr ( ) . cast_array ( ) ) } ) )
452
452
}
453
453
454
454
/// Returns a mutable array reference to the last `N` items in the slice and the remaining
@@ -482,7 +482,7 @@ impl<T> [T] {
482
482
// SAFETY: We explicitly check for the correct number of elements,
483
483
// do not let the reference outlive the slice,
484
484
// and enforce exclusive mutability of the chunk by the split.
485
- Some ( ( init, unsafe { & mut * ( last. as_mut_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } ) )
485
+ Some ( ( init, unsafe { & mut * ( last. as_mut_ptr ( ) . cast_array ( ) ) } ) )
486
486
}
487
487
488
488
/// Returns an array reference to the last `N` items in the slice.
@@ -511,7 +511,7 @@ impl<T> [T] {
511
511
512
512
// SAFETY: We explicitly check for the correct number of elements,
513
513
// and do not let the references outlive the slice.
514
- Some ( unsafe { & * ( last. as_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } )
514
+ Some ( unsafe { & * ( last. as_ptr ( ) . cast_array ( ) ) } )
515
515
}
516
516
517
517
/// Returns a mutable array reference to the last `N` items in the slice.
@@ -542,7 +542,7 @@ impl<T> [T] {
542
542
// SAFETY: We explicitly check for the correct number of elements,
543
543
// do not let the reference outlive the slice,
544
544
// and require exclusive access to the entire slice to mutate the chunk.
545
- Some ( unsafe { & mut * ( last. as_mut_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } )
545
+ Some ( unsafe { & mut * ( last. as_mut_ptr ( ) . cast_array ( ) ) } )
546
546
}
547
547
548
548
/// Returns a reference to an element or subslice depending on the type of
@@ -846,7 +846,7 @@ impl<T> [T] {
846
846
#[ must_use]
847
847
pub const fn as_array < const N : usize > ( & self ) -> Option < & [ T ; N ] > {
848
848
if self . len ( ) == N {
849
- let ptr = self . as_ptr ( ) as * const [ T ; N ] ;
849
+ let ptr = self . as_ptr ( ) . cast_array ( ) ;
850
850
851
851
// SAFETY: The underlying array of a slice can be reinterpreted as an actual array `[T; N]` if `N` is not greater than the slice's length.
852
852
let me = unsafe { & * ptr } ;
@@ -864,7 +864,7 @@ impl<T> [T] {
864
864
#[ must_use]
865
865
pub const fn as_mut_array < const N : usize > ( & mut self ) -> Option < & mut [ T ; N ] > {
866
866
if self . len ( ) == N {
867
- let ptr = self . as_mut_ptr ( ) as * mut [ T ; N ] ;
867
+ let ptr = self . as_mut_ptr ( ) . cast_array ( ) ;
868
868
869
869
// SAFETY: The underlying array of a slice can be reinterpreted as an actual array `[T; N]` if `N` is not greater than the slice's length.
870
870
let me = unsafe { & mut * ptr } ;
0 commit comments