diff options
| author | bors <bors@rust-lang.org> | 2017-04-11 12:13:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-04-11 12:13:49 +0000 |
| commit | c58c928e658d2e45f816fd05796a964aa83759da (patch) | |
| tree | cb73be229a48a5d32ecdaadcc34939e87d8dc0a3 /src/libstd | |
| parent | 6edc59685382d3ec0b6b89b05897a22a597c48a1 (diff) | |
| parent | a2b28be3f8f2920d39c9c87fef968d3885753ba4 (diff) | |
| download | rust-c58c928e658d2e45f816fd05796a964aa83759da.tar.gz rust-c58c928e658d2e45f816fd05796a964aa83759da.zip | |
Auto merge of #41096 - clarcharr:as_bytes_mut, r=alexcrichton
Reduce str transmutes, add mut versions of methods. When I was working on the various parts involved in #40380 one of the comments I got was the excess of transmutes necessary to make the changes work. This is part of a set of multiple changes I'd like to offer to fix this problem. I think that having these methods is reasonable because they're already possible via transmutes, and it makes the code that uses them safer. I can also add `pub(crate)` to these methods for now if the libs team would rather not expose them to the public without an RFC.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ascii.rs | 5 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 1 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index b3625386209..4e3781ecafa 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -27,7 +27,6 @@ #![stable(feature = "rust1", since = "1.0.0")] use fmt; -use mem; use ops::Range; use iter::FusedIterator; @@ -599,12 +598,12 @@ impl AsciiExt for str { } fn make_ascii_uppercase(&mut self) { - let me: &mut [u8] = unsafe { mem::transmute(self) }; + let me = unsafe { self.as_bytes_mut() }; me.make_ascii_uppercase() } fn make_ascii_lowercase(&mut self) { - let me: &mut [u8] = unsafe { mem::transmute(self) }; + let me = unsafe { self.as_bytes_mut() }; me.make_ascii_lowercase() } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 064144dcd68..6299a9070ae 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -296,6 +296,7 @@ #![feature(stmt_expr_attributes)] #![feature(str_char)] #![feature(str_internals)] +#![feature(str_mut_extras)] #![feature(str_utf16)] #![feature(test, rustc_private)] #![feature(thread_local)] |
