[][src]Function morton_encoding::bloat_custom_checked

pub fn bloat_custom_checked<Coor, Key>(
    x: Coor,
    siz_rat: NonZeroUsize
) -> Option<Key> where
    Coor: ToPrimitive,
    Key: ValidKey<Coor>, 

"Bloats" a given number, interleaving its bits with a user-provided number of 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 preferable when the size ratio is computed at run-time.

Examples

assert_eq!(bloat_custom_checked(0xFFFFu16, nz(2)), Some(0x55555555u32));
assert_eq!(bloat_custom_checked::<u16, u32>(0xFFFF, nz(3)), None);