pub const fn cast<T, U>(from: T, _bounds: (ImplsPod<T>, ImplsPod<U>)) -> U
Expand description
For casting T
into U
Requires both T
and U
to implement Pod
.
This panics if T
is not the same size as U
use constmuck::{cast, infer};
const LE_BYTES: [u8; 4] = cast(0xAB1E_BEEF_u32.to_le(), infer!());
assert_eq!(LE_BYTES, 0xAB1E_BEEF_u32.to_le_bytes());