mirror of
https://github.com/openharmony/third_party_rust_libloading.git
synced 2026-07-20 05:34:25 -04:00
Use mem::transmute not manual pointer casting
This avoids an `alloca` in optimised code and looks less heavy to read.
This commit is contained in:
+2
-1
@@ -179,7 +179,8 @@ impl<T> ::std::ops::Deref for Symbol<T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &T {
|
||||
unsafe {
|
||||
&*(&self.pointer as *const _ as *const T)
|
||||
// Additional reference level for a dereference on `deref` return value.
|
||||
::std::mem::transmute(&self.pointer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,8 @@ impl<T> ::std::ops::Deref for Symbol<T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &T {
|
||||
unsafe {
|
||||
&*(&self.pointer as *const _ as *const T)
|
||||
// Additional reference level for a dereference on `deref` return value.
|
||||
::std::mem::transmute(&self.pointer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user