Skip to content

Commit

Permalink
std: Stabilize the str_{mut,box}_extras feature
Browse files Browse the repository at this point in the history
Stabilizes

* `<&mut str>::as_bytes_mut`
* `<Box<str>>::into_boxed_bytes`
* `std::str::from_boxed_utf8_unchecked`
* `std::str::from_utf8_mut`
* `std::str::from_utf8_unchecked_mut`

Closes #41119
  • Loading branch information
alexcrichton committed Jul 25, 2017
1 parent 20b4f86 commit 16707d4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Expand Up @@ -115,7 +115,6 @@
#![feature(specialization)]
#![feature(staged_api)]
#![feature(str_internals)]
#![feature(str_mut_extras)]
#![feature(trusted_len)]
#![feature(unboxed_closures)]
#![feature(unicode)]
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/str.rs
Expand Up @@ -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)
Expand Down Expand Up @@ -1725,7 +1725,7 @@ impl str {
}

/// Converts a `Box<str>` 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<str>) -> Box<[u8]> {
self.into()
}
Expand Down Expand Up @@ -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<str> {
mem::transmute(v)
}
6 changes: 3 additions & 3 deletions src/libcore/str/mod.rs
Expand Up @@ -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) })
Expand Down Expand Up @@ -382,7 +382,7 @@ pub unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
///
/// [fromutf8]: fn.from_utf8_unchecked.html
#[inline]
#[unstable(feature = "str_mut_extras", issue = "41119")]
#[stable(feature = "str_mut_extras", since = "1.20.0")]
pub unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {
mem::transmute(v)
}
Expand Down Expand Up @@ -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<usize>;
Expand Down
6 changes: 0 additions & 6 deletions src/libstd/ffi/c_str.rs
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions src/libstd/ffi/os_str.rs
Expand Up @@ -252,8 +252,6 @@ impl OsString {
/// # Examples
///
/// ```
/// #![feature(into_boxed_os_str)]
///
/// use std::ffi::{OsString, OsStr};
///
/// let s = OsString::from("hello");
Expand Down
1 change: 0 additions & 1 deletion src/libstd/lib.rs
Expand Up @@ -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)]
Expand Down

0 comments on commit 16707d4

Please sign in to comment.