@@ -328,7 +328,7 @@ impl<T> [T] {
328328 } else {
329329 // SAFETY: We explicitly check for the correct number of elements,
330330 // 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 ( ) ) } )
332332 }
333333 }
334334
@@ -359,7 +359,7 @@ impl<T> [T] {
359359 // SAFETY: We explicitly check for the correct number of elements,
360360 // do not let the reference outlive the slice,
361361 // 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 ( ) ) } )
363363 }
364364 }
365365
@@ -387,7 +387,7 @@ impl<T> [T] {
387387
388388 // SAFETY: We explicitly check for the correct number of elements,
389389 // 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) )
391391 }
392392
393393 /// Returns a mutable array reference to the first `N` items in the slice and the remaining
@@ -420,7 +420,7 @@ impl<T> [T] {
420420 // SAFETY: We explicitly check for the correct number of elements,
421421 // do not let the reference outlive the slice,
422422 // 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) )
424424 }
425425
426426 /// Returns an array reference to the last `N` items in the slice and the remaining slice.
@@ -448,7 +448,7 @@ impl<T> [T] {
448448
449449 // SAFETY: We explicitly check for the correct number of elements,
450450 // 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 ( ) ) } ) )
452452 }
453453
454454 /// Returns a mutable array reference to the last `N` items in the slice and the remaining
@@ -482,7 +482,7 @@ impl<T> [T] {
482482 // SAFETY: We explicitly check for the correct number of elements,
483483 // do not let the reference outlive the slice,
484484 // 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 ( ) ) } ) )
486486 }
487487
488488 /// Returns an array reference to the last `N` items in the slice.
@@ -511,7 +511,7 @@ impl<T> [T] {
511511
512512 // SAFETY: We explicitly check for the correct number of elements,
513513 // 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 ( ) ) } )
515515 }
516516
517517 /// Returns a mutable array reference to the last `N` items in the slice.
@@ -542,7 +542,7 @@ impl<T> [T] {
542542 // SAFETY: We explicitly check for the correct number of elements,
543543 // do not let the reference outlive the slice,
544544 // 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 ( ) ) } )
546546 }
547547
548548 /// Returns a reference to an element or subslice depending on the type of
@@ -846,7 +846,7 @@ impl<T> [T] {
846846 #[ must_use]
847847 pub const fn as_array < const N : usize > ( & self ) -> Option < & [ T ; N ] > {
848848 if self . len ( ) == N {
849- let ptr = self . as_ptr ( ) as * const [ T ; N ] ;
849+ let ptr = self . as_ptr ( ) . cast_array ( ) ;
850850
851851 // 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.
852852 let me = unsafe { & * ptr } ;
@@ -864,7 +864,7 @@ impl<T> [T] {
864864 #[ must_use]
865865 pub const fn as_mut_array < const N : usize > ( & mut self ) -> Option < & mut [ T ; N ] > {
866866 if self . len ( ) == N {
867- let ptr = self . as_mut_ptr ( ) as * mut [ T ; N ] ;
867+ let ptr = self . as_mut_ptr ( ) . cast_array ( ) ;
868868
869869 // 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.
870870 let me = unsafe { & mut * ptr } ;
0 commit comments