Function morton_encoding::bloat_custom [−][src]
pub fn bloat_custom<Coor, Key, const N: usize>(x: Coor) -> Key where
Coor: ToPrimitive,
Key: ValidKey<Coor>,
“Bloats” a given number by interleaving its bits with zeroes.
Each input bit is interleaved with N - 1
zeroes.
Examples
assert_eq!(bloat_custom::<_, u32, 3>(0x55u8), 0x041041);
Panics
With the advent of min_const_generics
in this crate, it was
hoped that this function could recognise when a Key
value
is not large enough for N
Coor
values, and fail to compile
in that case. Sadly, the compiler isn’t quite clever enough for that yet.
Thus, we have to make do with run-time panics instead, as seen in the
following example:
ⓘ
bloat_custom::<u8, u16, 3>(0x55u8); // Compiles, but panics.
Therefore, the user is solely responsible for maintaining the invariants needed.