mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-17 09:26:37 +00:00
feat: stabilize split_at_checked
This commit is contained in:
parent
20aa2d81e3
commit
4c286c7f9a
@ -187,7 +187,6 @@
|
|||||||
#![feature(ptr_metadata)]
|
#![feature(ptr_metadata)]
|
||||||
#![feature(set_ptr_value)]
|
#![feature(set_ptr_value)]
|
||||||
#![feature(slice_ptr_get)]
|
#![feature(slice_ptr_get)]
|
||||||
#![feature(split_at_checked)]
|
|
||||||
#![feature(str_internals)]
|
#![feature(str_internals)]
|
||||||
#![feature(str_split_inclusive_remainder)]
|
#![feature(str_split_inclusive_remainder)]
|
||||||
#![feature(str_split_remainder)]
|
#![feature(str_split_remainder)]
|
||||||
|
|||||||
@ -2051,8 +2051,6 @@ impl<T> [T] {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(split_at_checked)]
|
|
||||||
///
|
|
||||||
/// let v = [1, -2, 3, -4, 5, -6];
|
/// let v = [1, -2, 3, -4, 5, -6];
|
||||||
///
|
///
|
||||||
/// {
|
/// {
|
||||||
@ -2075,8 +2073,8 @@ impl<T> [T] {
|
|||||||
///
|
///
|
||||||
/// assert_eq!(None, v.split_at_checked(7));
|
/// assert_eq!(None, v.split_at_checked(7));
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "split_at_checked", reason = "new API", issue = "119128")]
|
#[stable(feature = "split_at_checked", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[rustc_const_unstable(feature = "split_at_checked", issue = "119128")]
|
#[rustc_const_stable(feature = "split_at_checked", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn split_at_checked(&self, mid: usize) -> Option<(&[T], &[T])> {
|
pub const fn split_at_checked(&self, mid: usize) -> Option<(&[T], &[T])> {
|
||||||
@ -2102,8 +2100,6 @@ impl<T> [T] {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(split_at_checked)]
|
|
||||||
///
|
|
||||||
/// let mut v = [1, 0, 3, 0, 5, 6];
|
/// let mut v = [1, 0, 3, 0, 5, 6];
|
||||||
///
|
///
|
||||||
/// if let Some((left, right)) = v.split_at_mut_checked(2) {
|
/// if let Some((left, right)) = v.split_at_mut_checked(2) {
|
||||||
@ -2116,8 +2112,8 @@ impl<T> [T] {
|
|||||||
///
|
///
|
||||||
/// assert_eq!(None, v.split_at_mut_checked(7));
|
/// assert_eq!(None, v.split_at_mut_checked(7));
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "split_at_checked", reason = "new API", issue = "119128")]
|
#[stable(feature = "split_at_checked", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[rustc_const_unstable(feature = "split_at_checked", issue = "119128")]
|
#[rustc_const_unstable(feature = "const_slice_split_at_mut", issue = "101804")]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut [T], &mut [T])> {
|
pub const fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut [T], &mut [T])> {
|
||||||
|
|||||||
@ -721,8 +721,6 @@ impl str {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(split_at_checked)]
|
|
||||||
///
|
|
||||||
/// let s = "Per Martin-Löf";
|
/// let s = "Per Martin-Löf";
|
||||||
///
|
///
|
||||||
/// let (first, last) = s.split_at_checked(3).unwrap();
|
/// let (first, last) = s.split_at_checked(3).unwrap();
|
||||||
@ -734,7 +732,7 @@ impl str {
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[unstable(feature = "split_at_checked", reason = "new API", issue = "119128")]
|
#[stable(feature = "split_at_checked", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn split_at_checked(&self, mid: usize) -> Option<(&str, &str)> {
|
pub fn split_at_checked(&self, mid: usize) -> Option<(&str, &str)> {
|
||||||
// is_char_boundary checks that the index is in [0, .len()]
|
// is_char_boundary checks that the index is in [0, .len()]
|
||||||
if self.is_char_boundary(mid) {
|
if self.is_char_boundary(mid) {
|
||||||
@ -761,8 +759,6 @@ impl str {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(split_at_checked)]
|
|
||||||
///
|
|
||||||
/// let mut s = "Per Martin-Löf".to_string();
|
/// let mut s = "Per Martin-Löf".to_string();
|
||||||
/// if let Some((first, last)) = s.split_at_mut_checked(3) {
|
/// if let Some((first, last)) = s.split_at_mut_checked(3) {
|
||||||
/// first.make_ascii_uppercase();
|
/// first.make_ascii_uppercase();
|
||||||
@ -776,7 +772,7 @@ impl str {
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[unstable(feature = "split_at_checked", reason = "new API", issue = "119128")]
|
#[stable(feature = "split_at_checked", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut str, &mut str)> {
|
pub fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut str, &mut str)> {
|
||||||
// is_char_boundary checks that the index is in [0, .len()]
|
// is_char_boundary checks that the index is in [0, .len()]
|
||||||
if self.is_char_boundary(mid) {
|
if self.is_char_boundary(mid) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user