pub fn bloat_custom_checked<Coor, Key>(
x: Coor,
siz_rat: NonZeroUsize,
) -> Option<Key>where
Coor: ToPrimitive,
Key: ValidKey<Coor>,Expand description
Fallibly “bloats” a given number, interleaving its bits with zeroes.
Returns an Option.
Each input bit is interleaved with siz_rat - 1 zeroes.
Alternatively, if the provided Key type is too small to
fit siz_rat Coor numbers inside it, a None is returned.
This function is usable when the size ratio is computed at run-time, but bear in mind that it might run much more slowly than its compile-time counterparts.
§Examples
assert_eq!(bloat_custom_checked(0xFFFFu16, nz(2)), Some(0x55555555u32));
assert_eq!(bloat_custom_checked::<u16, u32>(0xFFFF, nz(3)), None);