Replace many uses of mem::transmute with more specific functions

The replacements are functions that usually use a single `mem::transmute` in
their body and restrict input and output via more concrete types than `T` and
`U`. Worth noting are the `transmute` functions for slices and the `from_utf8*`
family for mutable slices. Additionally, `mem::transmute` was often used for
casting raw pointers, when you can already cast raw pointers just fine with
`as`.
This commit is contained in:
Tobias Bucher
2015-07-24 03:04:55 +02:00
parent febdc3b201
commit 22ec5f4af7
34 changed files with 187 additions and 103 deletions

View File

@@ -15,7 +15,6 @@
use prelude::v1::*;
use ops::Range;
use mem;
/// Extension methods for ASCII-subset only operations on owned strings
#[unstable(feature = "owned_ascii_ext",
@@ -186,12 +185,12 @@ impl AsciiExt for str {
}
fn make_ascii_uppercase(&mut self) {
let me: &mut [u8] = unsafe { mem::transmute(self) };
let me: &mut [u8] = 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: &mut [u8] = unsafe { self.as_bytes_mut() };
me.make_ascii_lowercase()
}
}