::std::ops::

Function interleave

pub fn interleave<#uint N>(l: uint<N>, r: uint<N>) -> uint<{ 2 * N }>
Expand

Interleaves the bits of two numbers.

A number containing bits from both input numbers is built, with even positions occupied by bits from the first number and odd positions occupied by those from the second number. In other words, given two numbers 0bCBA and 0b321, the output would be 0b3C2B1A.

Examples

assert 0b011u3.interleave(0b101u3) == 0b100111u6;
assert 0u0.interleave(0u0) == 0u0;