Skip to content

Commit 5309fbb

Browse files
committed
Make str::as_bytes_mut private
1 parent 47041fe commit 5309fbb

File tree

4 files changed

+3
-22
lines changed

4 files changed

+3
-22
lines changed

src/libcollections/str.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -479,19 +479,6 @@ impl str {
479479
core_str::StrExt::as_bytes(self)
480480
}
481481

482-
/// Converts `self` to a mutable byte slice.
483-
///
484-
/// # Unsafety
485-
///
486-
/// The `str` type guarantees that its contents are UTF-8 bytes, which can
487-
/// be violated using this function, leading to memory-unsafeties in other
488-
/// string functions.
489-
#[unstable(feature = "str_as_bytes_mut")]
490-
#[inline(always)]
491-
pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] {
492-
core_str::StrExt::as_bytes_mut(self)
493-
}
494-
495482
/// Returns a raw pointer to the `&str`'s buffer.
496483
///
497484
/// The caller must ensure that the string outlives this pointer, and

src/libcore/str/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,6 @@ pub trait StrExt {
12641264
fn char_at(&self, i: usize) -> char;
12651265
fn char_at_reverse(&self, i: usize) -> char;
12661266
fn as_bytes<'a>(&'a self) -> &'a [u8];
1267-
unsafe fn as_bytes_mut<'a>(&'a mut self) -> &'a mut [u8];
12681267
fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>;
12691268
fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>
12701269
where P::Searcher: ReverseSearcher<'a>;
@@ -1557,11 +1556,6 @@ impl StrExt for str {
15571556
unsafe { mem::transmute(self) }
15581557
}
15591558

1560-
#[inline]
1561-
unsafe fn as_bytes_mut(&mut self) -> &mut [u8] {
1562-
mem::transmute(self)
1563-
}
1564-
15651559
fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize> {
15661560
pat.into_searcher(self).next_match().map(|(i, _)| i)
15671561
}

src/libstd/ascii.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use prelude::v1::*;
1616

17+
use mem;
1718
use ops::Range;
1819

1920
/// Extension methods for ASCII-subset only operations on owned strings
@@ -185,12 +186,12 @@ impl AsciiExt for str {
185186
}
186187

187188
fn make_ascii_uppercase(&mut self) {
188-
let me: &mut [u8] = unsafe { self.as_bytes_mut() };
189+
let me: &mut [u8] = unsafe { mem::transmute(self) };
189190
me.make_ascii_uppercase()
190191
}
191192

192193
fn make_ascii_lowercase(&mut self) {
193-
let me: &mut [u8] = unsafe { self.as_bytes_mut() };
194+
let me: &mut [u8] = unsafe { mem::transmute(self) };
194195
me.make_ascii_lowercase()
195196
}
196197
}

src/libstd/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@
235235
#![feature(slice_bytes)]
236236
#![feature(slice_patterns)]
237237
#![feature(staged_api)]
238-
#![feature(str_as_bytes_mut)]
239238
#![feature(str_char)]
240239
#![feature(str_internals)]
241240
#![feature(unboxed_closures)]

0 commit comments

Comments
 (0)