Function std::mem::transmute_copyStable
[-]
[+]
[src]
pub unsafe fn transmute_copy<T, U>(src: &T) -> U
Interprets src as &U, and then reads src without moving the contained value.
This function will unsafely assume the pointer src is valid for sizeof(U) bytes by
transmuting &T to &U and then reading the &U. It will also unsafely create a copy of the
contained value instead of moving out of src.
It is not a compile-time error if T and U have different sizes, but it is highly encouraged
to only invoke this function where T and U have the same size. This function triggers
undefined behavior if U is larger than T.
Examples
fn main() { use std::mem; let one = unsafe { mem::transmute_copy(&1i) }; assert_eq!(1u, one); }use std::mem; let one = unsafe { mem::transmute_copy(&1i) }; assert_eq!(1u, one);