pub const fn u16_into_u8<const N: u16>() -> u8Expand description
Performs a build-time safe conversion of a u16 constant value into a u8.
This checks at compile-time that the conversion is lossless, and triggers a build error if it isn’t.
§Examples
use kernel::num::casts;
// Succeeds because the value of the source fits into the destination's type.
assert_eq!(casts::u16_into_u8::<1u16>(), 1u8);