pub const fn safe_transmute<Src: IntoBytes, Dst: FromBytes>(val: Src) -> DstExpand description
Safely transmutes a value of one type to a value of another type of the same size.
The sizes are checked during monomorphization.
This can be considered as generic version of [zerocopy::transmute!] macro that defers the size
check and thus can be used in more cases.
ยงExamples
fn to_u32<T: FromBytes + IntoBytes>(v: T) -> u32 {
// `zerocopy::transmute!` won't work here.
kernel::mem::safe_transmute(v)
}
to_u32(1i32);