@@ -330,7 +330,7 @@ impl<T> [T] {
330
330
} else {
331
331
// SAFETY: We explicitly check for the correct number of elements,
332
332
// and do not let the reference outlive the slice.
333
- Some ( unsafe { & * ( self . as_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } )
333
+ Some ( unsafe { & * ( self . as_ptr ( ) . cast_array ( ) ) } )
334
334
}
335
335
}
336
336
@@ -361,7 +361,7 @@ impl<T> [T] {
361
361
// SAFETY: We explicitly check for the correct number of elements,
362
362
// do not let the reference outlive the slice,
363
363
// and require exclusive access to the entire slice to mutate the chunk.
364
- Some ( unsafe { & mut * ( self . as_mut_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } )
364
+ Some ( unsafe { & mut * ( self . as_mut_ptr ( ) . cast_array ( ) ) } )
365
365
}
366
366
}
367
367
@@ -389,7 +389,7 @@ impl<T> [T] {
389
389
390
390
// SAFETY: We explicitly check for the correct number of elements,
391
391
// and do not let the references outlive the slice.
392
- Some ( ( unsafe { & * ( first. as_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } , tail) )
392
+ Some ( ( unsafe { & * ( first. as_ptr ( ) . cast_array ( ) ) } , tail) )
393
393
}
394
394
395
395
/// Returns a mutable array reference to the first `N` items in the slice and the remaining
@@ -422,7 +422,7 @@ impl<T> [T] {
422
422
// SAFETY: We explicitly check for the correct number of elements,
423
423
// do not let the reference outlive the slice,
424
424
// and enforce exclusive mutability of the chunk by the split.
425
- Some ( ( unsafe { & mut * ( first. as_mut_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } , tail) )
425
+ Some ( ( unsafe { & mut * ( first. as_mut_ptr ( ) . cast_array ( ) ) } , tail) )
426
426
}
427
427
428
428
/// Returns an array reference to the last `N` items in the slice and the remaining slice.
@@ -450,7 +450,7 @@ impl<T> [T] {
450
450
451
451
// SAFETY: We explicitly check for the correct number of elements,
452
452
// and do not let the references outlive the slice.
453
- Some ( ( init, unsafe { & * ( last. as_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } ) )
453
+ Some ( ( init, unsafe { & * ( last. as_ptr ( ) . cast_array ( ) ) } ) )
454
454
}
455
455
456
456
/// Returns a mutable array reference to the last `N` items in the slice and the remaining
@@ -484,7 +484,7 @@ impl<T> [T] {
484
484
// SAFETY: We explicitly check for the correct number of elements,
485
485
// do not let the reference outlive the slice,
486
486
// and enforce exclusive mutability of the chunk by the split.
487
- Some ( ( init, unsafe { & mut * ( last. as_mut_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } ) )
487
+ Some ( ( init, unsafe { & mut * ( last. as_mut_ptr ( ) . cast_array ( ) ) } ) )
488
488
}
489
489
490
490
/// Returns an array reference to the last `N` items in the slice.
@@ -513,7 +513,7 @@ impl<T> [T] {
513
513
514
514
// SAFETY: We explicitly check for the correct number of elements,
515
515
// and do not let the references outlive the slice.
516
- Some ( unsafe { & * ( last. as_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } )
516
+ Some ( unsafe { & * ( last. as_ptr ( ) . cast_array ( ) ) } )
517
517
}
518
518
519
519
/// Returns a mutable array reference to the last `N` items in the slice.
@@ -544,7 +544,7 @@ impl<T> [T] {
544
544
// SAFETY: We explicitly check for the correct number of elements,
545
545
// do not let the reference outlive the slice,
546
546
// and require exclusive access to the entire slice to mutate the chunk.
547
- Some ( unsafe { & mut * ( last. as_mut_ptr ( ) . cast :: < [ T ; N ] > ( ) ) } )
547
+ Some ( unsafe { & mut * ( last. as_mut_ptr ( ) . cast_array ( ) ) } )
548
548
}
549
549
550
550
/// Returns a reference to an element or subslice depending on the type of
@@ -848,7 +848,7 @@ impl<T> [T] {
848
848
#[ must_use]
849
849
pub const fn as_array < const N : usize > ( & self ) -> Option < & [ T ; N ] > {
850
850
if self . len ( ) == N {
851
- let ptr = self . as_ptr ( ) as * const [ T ; N ] ;
851
+ let ptr = self . as_ptr ( ) . cast_array ( ) ;
852
852
853
853
// 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.
854
854
let me = unsafe { & * ptr } ;
@@ -866,7 +866,7 @@ impl<T> [T] {
866
866
#[ must_use]
867
867
pub const fn as_mut_array < const N : usize > ( & mut self ) -> Option < & mut [ T ; N ] > {
868
868
if self . len ( ) == N {
869
- let ptr = self . as_mut_ptr ( ) as * mut [ T ; N ] ;
869
+ let ptr = self . as_mut_ptr ( ) . cast_array ( ) ;
870
870
871
871
// 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.
872
872
let me = unsafe { & mut * ptr } ;
0 commit comments