]> git.lizzy.rs Git - rust.git/commitdiff
Make `str::as_bytes_mut` private
authorTobias Bucher <tobiasbucher5991@gmail.com>
Fri, 24 Jul 2015 20:10:12 +0000 (22:10 +0200)
committerTobias Bucher <tobiasbucher5991@gmail.com>
Sun, 9 Aug 2015 20:05:22 +0000 (22:05 +0200)
src/libcollections/str.rs
src/libcore/str/mod.rs
src/libstd/ascii.rs
src/libstd/lib.rs

index d359d7548f3f129a21f3852bee5f5368d06fd4d1..2d56e6e3c417a8d660d4fbc1a0a90b35263e0cb8 100644 (file)
@@ -479,19 +479,6 @@ pub fn as_bytes(&self) -> &[u8] {
         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
index 202fc90b40d22d90a35ce08a31650a9eca072814..3c9338c2cd29cbf796430498d7342f90e2727249 100644 (file)
@@ -1264,7 +1264,6 @@ fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
     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 @@ fn as_bytes(&self) -> &[u8] {
         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)
     }
index f003948be7bfe335035d151c51b2958b3271dabd..ded572e82ff9aa5f02906bfcc0c9cf755ddfe520 100644 (file)
@@ -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 @@ fn eq_ignore_ascii_case(&self, other: &str) -> bool {
     }
 
     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()
     }
 }
index b4bbb3f25f7ba72a4aad1f24aa488666205fe1a7..7baa7558e52d57fb9fdf9ce0c3e69a0a38f607c0 100644 (file)
 #![feature(slice_bytes)]
 #![feature(slice_patterns)]
 #![feature(staged_api)]
-#![feature(str_as_bytes_mut)]
 #![feature(str_char)]
 #![feature(str_internals)]
 #![feature(unboxed_closures)]