::std::conv::

Function int_to_bits

pub fn int_to_bits<#uint N>(input: int<N>) -> [bool; N]
Expand

Casts a signed integer to an array of bool by reinterpreting its bits.

Bits are laid out from LSB to MSB, so the first element of the array corresponds to the LSB of the input number and the last element corresponds to its MSB.

Note that bits in the literal binary representation are written right-to-left, while items in the literal representation of the array are written left-to-right.

Examples

assert int_to_bits(0i0) == [];
assert int_to_bits(0b0111i4) == [true, true, true, false];
assert int_to_bits(-0b0001i4) == [true, true, true, true];