Skip to content

Commit 02e91fe

Browse files
committed
Use cast_array in core
1 parent 7ead576 commit 02e91fe

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

library/core/src/slice/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl<T> [T] {
330330
} else {
331331
// SAFETY: We explicitly check for the correct number of elements,
332332
// 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()) })
334334
}
335335
}
336336

@@ -361,7 +361,7 @@ impl<T> [T] {
361361
// SAFETY: We explicitly check for the correct number of elements,
362362
// do not let the reference outlive the slice,
363363
// 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()) })
365365
}
366366
}
367367

@@ -389,7 +389,7 @@ impl<T> [T] {
389389

390390
// SAFETY: We explicitly check for the correct number of elements,
391391
// 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))
393393
}
394394

395395
/// Returns a mutable array reference to the first `N` items in the slice and the remaining
@@ -422,7 +422,7 @@ impl<T> [T] {
422422
// SAFETY: We explicitly check for the correct number of elements,
423423
// do not let the reference outlive the slice,
424424
// 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))
426426
}
427427

428428
/// Returns an array reference to the last `N` items in the slice and the remaining slice.
@@ -450,7 +450,7 @@ impl<T> [T] {
450450

451451
// SAFETY: We explicitly check for the correct number of elements,
452452
// 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()) }))
454454
}
455455

456456
/// Returns a mutable array reference to the last `N` items in the slice and the remaining
@@ -484,7 +484,7 @@ impl<T> [T] {
484484
// SAFETY: We explicitly check for the correct number of elements,
485485
// do not let the reference outlive the slice,
486486
// 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()) }))
488488
}
489489

490490
/// Returns an array reference to the last `N` items in the slice.
@@ -513,7 +513,7 @@ impl<T> [T] {
513513

514514
// SAFETY: We explicitly check for the correct number of elements,
515515
// 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()) })
517517
}
518518

519519
/// Returns a mutable array reference to the last `N` items in the slice.
@@ -544,7 +544,7 @@ impl<T> [T] {
544544
// SAFETY: We explicitly check for the correct number of elements,
545545
// do not let the reference outlive the slice,
546546
// 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()) })
548548
}
549549

550550
/// Returns a reference to an element or subslice depending on the type of

0 commit comments

Comments
 (0)