pub fn morton_encode_generic<Coor, Key, Coors>(coors: Coors) -> Keywhere
Coor: ToPrimitive,
Key: ValidKey<Coor>,
Coors: IntoIterator<Item = Coor>,
<Coors as IntoIterator>::IntoIter: ExactSizeIterator,Expand description
Receives an iterator of Coor values and encodes them all in a Key value.
Meant to be used with statically-known iterator lengths. If that is not
the case, the checked version of this function (morton_encode_checked)
should be used instead.
§Panics
This function will panic if the Key value provided does not have enough
length for all the values in the iterator.
In the future, we would like to constrain it for iterators that have exactly
const N elements, but that’s still quite far away.
§Examples
let input = vec!(0u8, 255);
let result: u16 = morton_encode_generic(input);
assert_eq!(result, 0x5555);In the event that one Key is strictly larger than all Coors put together, all significant bits are gathered at the end, and extraneous bits at the beginning are cleared. The following example illustrates the difference:
let input = vec!(255u8; 3);
let result: u32 = morton_encode_generic(input);
assert_eq!(result, 0b_0000_0000_111_111_111_111_111_111_111_111u32);
let input = vec!(0u8, 255, 255, 255);
let result: u32 = morton_encode_generic(input);
assert_eq!(result, 0b_0111_0111_0111_0111_0111_0111_0111_0111u32);