Make str::as_bytes_mut private
This commit is contained in:
parent
47041fe289
commit
5309fbb6c9
4 changed files with 3 additions and 22 deletions
|
|
@ -479,19 +479,6 @@ impl str {
|
|||
core_str::StrExt::as_bytes(self)
|
||||
}
|
||||
|
||||
/// Converts `self` to a mutable byte slice.
|
||||
///
|
||||
/// # Unsafety
|
||||
///
|
||||
/// The `str` type guarantees that its contents are UTF-8 bytes, which can
|
||||
/// be violated using this function, leading to memory-unsafeties in other
|
||||
/// string functions.
|
||||
#[unstable(feature = "str_as_bytes_mut")]
|
||||
#[inline(always)]
|
||||
pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] {
|
||||
core_str::StrExt::as_bytes_mut(self)
|
||||
}
|
||||
|
||||
/// Returns a raw pointer to the `&str`'s buffer.
|
||||
///
|
||||
/// The caller must ensure that the string outlives this pointer, and
|
||||
|
|
|
|||
|
|
@ -1264,7 +1264,6 @@ pub trait StrExt {
|
|||
fn char_at(&self, i: usize) -> char;
|
||||
fn char_at_reverse(&self, i: usize) -> char;
|
||||
fn as_bytes<'a>(&'a self) -> &'a [u8];
|
||||
unsafe fn as_bytes_mut<'a>(&'a mut self) -> &'a mut [u8];
|
||||
fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>;
|
||||
fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>
|
||||
where P::Searcher: ReverseSearcher<'a>;
|
||||
|
|
@ -1557,11 +1556,6 @@ impl StrExt for str {
|
|||
unsafe { mem::transmute(self) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn as_bytes_mut(&mut self) -> &mut [u8] {
|
||||
mem::transmute(self)
|
||||
}
|
||||
|
||||
fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize> {
|
||||
pat.into_searcher(self).next_match().map(|(i, _)| i)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
use prelude::v1::*;
|
||||
|
||||
use mem;
|
||||
use ops::Range;
|
||||
|
||||
/// Extension methods for ASCII-subset only operations on owned strings
|
||||
|
|
@ -185,12 +186,12 @@ impl AsciiExt for str {
|
|||
}
|
||||
|
||||
fn make_ascii_uppercase(&mut self) {
|
||||
let me: &mut [u8] = unsafe { self.as_bytes_mut() };
|
||||
let me: &mut [u8] = unsafe { mem::transmute(self) };
|
||||
me.make_ascii_uppercase()
|
||||
}
|
||||
|
||||
fn make_ascii_lowercase(&mut self) {
|
||||
let me: &mut [u8] = unsafe { self.as_bytes_mut() };
|
||||
let me: &mut [u8] = unsafe { mem::transmute(self) };
|
||||
me.make_ascii_lowercase()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,7 +235,6 @@
|
|||
#![feature(slice_bytes)]
|
||||
#![feature(slice_patterns)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(str_as_bytes_mut)]
|
||||
#![feature(str_char)]
|
||||
#![feature(str_internals)]
|
||||
#![feature(unboxed_closures)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue