Function lindel::morton_encode[][src]

pub fn morton_encode<Coordinate, const N: usize>(
    input: [Coordinate; N]
) -> <Coordinate as IdealKey<N>>::Key where
    Coordinate: IdealKey<N> + ToPrimitive + PrimInt,
    <Coordinate as IdealKey<N>>::Key: ValidKey<Coordinate>, 

The most ergonomic way to perform the Morton encoding operation.

Works for all primitive unsigned integers, and never panics for them. Will work for others if the user implements the IdealKey trait for them, but will panic if the trait is misimplemented.


assert_eq!(morton_encode([0u8; 2]), 0u16);
assert_eq!(morton_encode([0u8; 3]), 0u32);
assert_eq!(morton_encode([0u32; 3]), 0u128);