@@ -1538,13 +1538,14 @@ impl<T> [T] {
15381538 /// }
15391539 /// ```
15401540 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1541+ #[ rustc_const_unstable( feature = "const_slice_split_at_not_mut" , issue = "none" ) ]
15411542 #[ inline]
15421543 #[ track_caller]
15431544 #[ must_use]
1544- pub fn split_at ( & self , mid : usize ) -> ( & [ T ] , & [ T ] ) {
1545+ pub const fn split_at ( & self , mid : usize ) -> ( & [ T ] , & [ T ] ) {
15451546 assert ! ( mid <= self . len( ) ) ;
15461547 // SAFETY: `[ptr; mid]` and `[mid; len]` are inside `self`, which
1547- // fulfills the requirements of `from_raw_parts_mut `.
1548+ // fulfills the requirements of `split_at_unchecked `.
15481549 unsafe { self . split_at_unchecked ( mid) }
15491550 }
15501551
@@ -1623,11 +1624,15 @@ impl<T> [T] {
16231624 /// }
16241625 /// ```
16251626 #[ unstable( feature = "slice_split_at_unchecked" , reason = "new API" , issue = "76014" ) ]
1627+ #[ rustc_const_unstable( feature = "const_slice_split_at_not_mut" , issue = "none" ) ]
16261628 #[ inline]
16271629 #[ must_use]
1628- pub unsafe fn split_at_unchecked ( & self , mid : usize ) -> ( & [ T ] , & [ T ] ) {
1630+ pub const unsafe fn split_at_unchecked ( & self , mid : usize ) -> ( & [ T ] , & [ T ] ) {
1631+ let len = self . len ( ) ;
1632+ let ptr = self . as_ptr ( ) ;
1633+
16291634 // SAFETY: Caller has to check that `0 <= mid <= self.len()`
1630- unsafe { ( self . get_unchecked ( .. mid) , self . get_unchecked ( mid.. ) ) }
1635+ unsafe { ( from_raw_parts ( ptr , mid) , from_raw_parts ( ptr . add ( mid) , len - mid ) ) }
16311636 }
16321637
16331638 /// Divides one mutable slice into two at an index, without doing bounds checking.
0 commit comments