Function constmuck::cast[][src]

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.

Panics

This panics if T is not the same size as U

Example

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());