From a2b855652cbf2de0caa2fae6240730d2db4a18de Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 20 Jul 2017 15:52:12 -0700 Subject: [PATCH] std: Stabilize the `str_{mut,box}_extras` feature Stabilizes * `<&mut str>::as_bytes_mut` * `>::into_boxed_bytes` * `std::str::from_boxed_utf8_unchecked` * `std::str::from_utf8_mut` * `std::str::from_utf8_unchecked_mut` Closes #41119 --- src/liballoc/lib.rs | 1 - src/liballoc/str.rs | 6 +++--- src/libcore/str/mod.rs | 8 ++++---- src/libstd/ffi/c_str.rs | 6 ------ src/libstd/ffi/os_str.rs | 2 -- src/libstd/lib.rs | 1 - 6 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 789c548238f53..7a5acb1856528 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -115,7 +115,6 @@ #![feature(specialization)] #![feature(staged_api)] #![feature(str_internals)] -#![feature(str_mut_extras)] #![feature(trusted_len)] #![feature(unboxed_closures)] #![feature(unicode)] diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index e4953988c5c12..4df13c509a835 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -290,7 +290,7 @@ impl str { } /// Converts a mutable string slice to a mutable byte slice. - #[unstable(feature = "str_mut_extras", issue = "41119")] + #[stable(feature = "str_mut_extras", since = "1.20.0")] #[inline(always)] pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] { core_str::StrExt::as_bytes_mut(self) @@ -1725,7 +1725,7 @@ impl str { } /// Converts a `Box` into a `Box<[u8]>` without copying or allocating. - #[unstable(feature = "str_box_extras", issue = "41119")] + #[stable(feature = "str_box_extras", since = "1.20.0")] pub fn into_boxed_bytes(self: Box) -> Box<[u8]> { self.into() } @@ -1992,7 +1992,7 @@ impl str { /// Converts a boxed slice of bytes to a boxed string slice without checking /// that the string contains valid UTF-8. -#[unstable(feature = "str_box_extras", issue = "41119")] +#[stable(feature = "str_box_extras", since = "1.20.0")] pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box { mem::transmute(v) } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 10cf3bd29c6ba..cc18222815c3b 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -301,7 +301,7 @@ pub fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> { } /// Converts a mutable slice of bytes to a mutable string slice. -#[unstable(feature = "str_mut_extras", issue = "41119")] +#[stable(feature = "str_mut_extras", since = "1.20.0")] pub fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> { run_utf8_validation(v)?; Ok(unsafe { from_utf8_unchecked_mut(v) }) @@ -381,8 +381,8 @@ pub unsafe fn from_utf8_unchecked(v: &[u8]) -> &str { /// See the immutable version, [`from_utf8_unchecked()`][fromutf8], for more information. /// /// [fromutf8]: fn.from_utf8_unchecked.html -#[inline(always)] -#[unstable(feature = "str_mut_extras", issue = "41119")] +#[inline] +#[stable(feature = "str_mut_extras", since = "1.20.0")] pub unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str { mem::transmute(v) } @@ -2123,7 +2123,7 @@ pub trait StrExt { fn is_char_boundary(&self, index: usize) -> bool; #[stable(feature = "core", since = "1.6.0")] fn as_bytes(&self) -> &[u8]; - #[unstable(feature = "str_mut_extras", issue = "41119")] + #[stable(feature = "str_mut_extras", since = "1.20.0")] unsafe fn as_bytes_mut(&mut self) -> &mut [u8]; #[stable(feature = "core", since = "1.6.0")] fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option; diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 5dd7bb1c0c1d9..db64d41011c6b 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -453,8 +453,6 @@ impl CString { /// # Examples /// /// ``` - /// #![feature(as_c_str)] - /// /// use std::ffi::{CString, CStr}; /// /// let c_string = CString::new(b"foo".to_vec()).unwrap(); @@ -474,8 +472,6 @@ impl CString { /// # Examples /// /// ``` - /// #![feature(into_boxed_c_str)] - /// /// use std::ffi::{CString, CStr}; /// /// let c_string = CString::new(b"foo".to_vec()).unwrap(); @@ -1001,8 +997,6 @@ impl CStr { /// # Examples /// /// ``` - /// #![feature(into_boxed_c_str)] - /// /// use std::ffi::CString; /// /// let c_string = CString::new(b"foo".to_vec()).unwrap(); diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 6f147ea0eeccb..d62e3e905e3ca 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -252,8 +252,6 @@ impl OsString { /// # Examples /// /// ``` - /// #![feature(into_boxed_os_str)] - /// /// use std::ffi::{OsString, OsStr}; /// /// let s = OsString::from("hello"); diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 8fe0ecfcf5397..82262f1551ac0 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -303,7 +303,6 @@ #![feature(stmt_expr_attributes)] #![feature(str_char)] #![feature(str_internals)] -#![feature(str_mut_extras)] #![feature(str_utf16)] #![feature(test, rustc_private)] #![feature(thread_local)]