Skip to content

Commit baea702

Browse files
Rollup merge of rust-lang#124678 - UserIsntAvailable:feat/stabilize-split-at-checked, r=jhpratt
Stabilize `split_at_checked` Closes rust-lang#119128 For the const version of `slice::split_at_mut_checked`, I'm reusing the `const_slice_split_at_mut` feature flag (rust-lang#101804). I don't if it okay to reuse tracking issues or if it preferred to create new ones...
2 parents 72c9580 + 4c286c7 commit baea702

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@
186186
#![feature(ptr_metadata)]
187187
#![feature(set_ptr_value)]
188188
#![feature(slice_ptr_get)]
189-
#![feature(split_at_checked)]
190189
#![feature(str_internals)]
191190
#![feature(str_split_inclusive_remainder)]
192191
#![feature(str_split_remainder)]

library/core/src/slice/mod.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -2051,8 +2051,6 @@ impl<T> [T] {
20512051
/// # Examples
20522052
///
20532053
/// ```
2054-
/// #![feature(split_at_checked)]
2055-
///
20562054
/// let v = [1, -2, 3, -4, 5, -6];
20572055
///
20582056
/// {
@@ -2075,8 +2073,8 @@ impl<T> [T] {
20752073
///
20762074
/// assert_eq!(None, v.split_at_checked(7));
20772075
/// ```
2078-
#[unstable(feature = "split_at_checked", reason = "new API", issue = "119128")]
2079-
#[rustc_const_unstable(feature = "split_at_checked", issue = "119128")]
2076+
#[stable(feature = "split_at_checked", since = "CURRENT_RUSTC_VERSION")]
2077+
#[rustc_const_stable(feature = "split_at_checked", since = "CURRENT_RUSTC_VERSION")]
20802078
#[inline]
20812079
#[must_use]
20822080
pub const fn split_at_checked(&self, mid: usize) -> Option<(&[T], &[T])> {
@@ -2102,8 +2100,6 @@ impl<T> [T] {
21022100
/// # Examples
21032101
///
21042102
/// ```
2105-
/// #![feature(split_at_checked)]
2106-
///
21072103
/// let mut v = [1, 0, 3, 0, 5, 6];
21082104
///
21092105
/// if let Some((left, right)) = v.split_at_mut_checked(2) {
@@ -2116,8 +2112,8 @@ impl<T> [T] {
21162112
///
21172113
/// assert_eq!(None, v.split_at_mut_checked(7));
21182114
/// ```
2119-
#[unstable(feature = "split_at_checked", reason = "new API", issue = "119128")]
2120-
#[rustc_const_unstable(feature = "split_at_checked", issue = "119128")]
2115+
#[stable(feature = "split_at_checked", since = "CURRENT_RUSTC_VERSION")]
2116+
#[rustc_const_unstable(feature = "const_slice_split_at_mut", issue = "101804")]
21212117
#[inline]
21222118
#[must_use]
21232119
pub const fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut [T], &mut [T])> {

library/core/src/str/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,6 @@ impl str {
721721
/// # Examples
722722
///
723723
/// ```
724-
/// #![feature(split_at_checked)]
725-
///
726724
/// let s = "Per Martin-Löf";
727725
///
728726
/// let (first, last) = s.split_at_checked(3).unwrap();
@@ -734,7 +732,7 @@ impl str {
734732
/// ```
735733
#[inline]
736734
#[must_use]
737-
#[unstable(feature = "split_at_checked", reason = "new API", issue = "119128")]
735+
#[stable(feature = "split_at_checked", since = "CURRENT_RUSTC_VERSION")]
738736
pub fn split_at_checked(&self, mid: usize) -> Option<(&str, &str)> {
739737
// is_char_boundary checks that the index is in [0, .len()]
740738
if self.is_char_boundary(mid) {
@@ -761,8 +759,6 @@ impl str {
761759
/// # Examples
762760
///
763761
/// ```
764-
/// #![feature(split_at_checked)]
765-
///
766762
/// let mut s = "Per Martin-Löf".to_string();
767763
/// if let Some((first, last)) = s.split_at_mut_checked(3) {
768764
/// first.make_ascii_uppercase();
@@ -776,7 +772,7 @@ impl str {
776772
/// ```
777773
#[inline]
778774
#[must_use]
779-
#[unstable(feature = "split_at_checked", reason = "new API", issue = "119128")]
775+
#[stable(feature = "split_at_checked", since = "CURRENT_RUSTC_VERSION")]
780776
pub fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut str, &mut str)> {
781777
// is_char_boundary checks that the index is in [0, .len()]
782778
if self.is_char_boundary(mid) {

0 commit comments

Comments
 (0)