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:
@@ -192,7 +192,7 @@ impl Error + 'static {
|
||||
let to: TraitObject = transmute(self);
|
||||
|
||||
// Extract the data pointer
|
||||
Some(transmute(to.data))
|
||||
Some(&*(to.data as *const T))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
@@ -210,7 +210,7 @@ impl Error + 'static {
|
||||
let to: TraitObject = transmute(self);
|
||||
|
||||
// Extract the data pointer
|
||||
Some(transmute(to.data))
|
||||
Some(&mut *(to.data as *const T as *mut T))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user