Skip to content

Commit 5051904

Browse files
committed
Auto merge of rust-lang#87870 - WaffleLapkin:pub_split_at_unchecked, r=dtolnay
Make `<[T]>::split_at_unchecked` and `<[T]>::split_at_mut_unchecked` public The methods were originally added in rust-lang#75936 (sdroege@30dc32b), but for some reason as private. Nevertheless, the methods have documentation and even a [tracking issue](rust-lang#76014). It's very weird to have a tracking issue for private methods and these methods may be useful outside of the standard library. As such, this PR makes the methods public.
2 parents 4479cb8 + 48dd2eb commit 5051904

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/core/src/slice/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ impl<T> [T] {
15561556
///
15571557
/// # Examples
15581558
///
1559-
/// ```compile_fail
1559+
/// ```
15601560
/// #![feature(slice_split_at_unchecked)]
15611561
///
15621562
/// let v = [1, 2, 3, 4, 5, 6];
@@ -1581,7 +1581,7 @@ impl<T> [T] {
15811581
/// ```
15821582
#[unstable(feature = "slice_split_at_unchecked", reason = "new API", issue = "76014")]
15831583
#[inline]
1584-
unsafe fn split_at_unchecked(&self, mid: usize) -> (&[T], &[T]) {
1584+
pub unsafe fn split_at_unchecked(&self, mid: usize) -> (&[T], &[T]) {
15851585
// SAFETY: Caller has to check that `0 <= mid <= self.len()`
15861586
unsafe { (self.get_unchecked(..mid), self.get_unchecked(mid..)) }
15871587
}
@@ -1605,7 +1605,7 @@ impl<T> [T] {
16051605
///
16061606
/// # Examples
16071607
///
1608-
/// ```compile_fail
1608+
/// ```
16091609
/// #![feature(slice_split_at_unchecked)]
16101610
///
16111611
/// let mut v = [1, 0, 3, 0, 5, 6];
@@ -1621,7 +1621,7 @@ impl<T> [T] {
16211621
/// ```
16221622
#[unstable(feature = "slice_split_at_unchecked", reason = "new API", issue = "76014")]
16231623
#[inline]
1624-
unsafe fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
1624+
pub unsafe fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
16251625
let len = self.len();
16261626
let ptr = self.as_mut_ptr();
16271627

0 commit comments

Comments
 (0)