You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
381 B
16 lines
381 B
use std::{
|
|
mem::size_of,
|
|
};
|
|
|
|
#[inline]
|
|
pub unsafe fn bytes<T,U>(input: T) -> U
|
|
where T: Copy,
|
|
U: Copy
|
|
{
|
|
//let _array: [(); size_of::<T>() - size_of::<U>()]; // rust is silly....
|
|
if size_of::<U>() < size_of::<T>() {
|
|
panic!("reinterpret: Expected at least {} bytes, got {}.", size_of::<T>(), size_of::<U>());
|
|
}
|
|
return *((&input as *const T) as *const U)
|
|
}
|