Primitive bool
Expand
true or false
Also: #bool Type Generic
Implementations
impl<#uint N> [bool; N]
where
N > 0,
fn reduce_and(self) -> bool
Reduces an array of bool into a single value by performing AND on all elements.
Examples
assert [true, true, true].reduce_and() == true;
assert [false, false, false].reduce_and() == false;
assert [false, true, true].reduce_and() == false;This operation is equivalent to the Verilog AND reduction operator &.
fn reduce_or(self) -> bool
Reduces an array of bool into a single value by performing OR on all elements.
Examples
assert [true, true, true].reduce_or() == true;
assert [false, false, false].reduce_or() == false;
assert [false, true, true].reduce_or() == true;This operation is equivalent to the Verilog OR reduction operator |.
fn reduce_xor(self) -> bool
Reduces an array of bool into a single value by performing XOR on all elements.
Examples
assert [true, true, true].reduce_xor() == true ^^ true ^^ true;
assert [false, false, false].reduce_xor() == false ^^ false ^^ false;
assert [false, true, true].reduce_xor() == false ^^ true ^^ true;This operation is equivalent to the Verilog OR reduction operator ^.
impl<#uint N> [bool; N]
pub fn as_int(self) -> int<N>
Casts a an array of bool to a signed integer 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 of the number are written right-to-left, while items in the literal representation of the array are written left-to-right.
Examples
assert [true, true, true, false].as_int() == 0b0111i4;
assert [true, true, true, true].as_int() == -0b0001i4;pub fn as_uint(self) -> uint<N>
Casts an array of bool to an unsigned integer 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 of the number are written right-to-left, while items in the literal representation of the array are written left-to-right.
Examples
assert [true, false, true, true].as_uint() == 0b1101u4;pub fn to_int(self) -> int<N>
Casts a an array of bool to a signed integer 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 of the number are written right-to-left, while items in the literal representation of the array are written left-to-right.
Examples
assert [true, true, true, false].to_int() == 0b0111i4;
assert [true, true, true, true].to_int() == -0b0001i4;pub fn to_uint(self) -> uint<N>
Casts an array of bool to an unsigned integer 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 of the number are written right-to-left, while items in the literal representation of the array are written left-to-right.
Examples
assert empty.to_uint() == 0u0;
assert [true, false, true, true].to_uint() == 0b1101u4;impl bool
pub unsafe fn as_clock(self) -> clock
Casts a bool to a clock signal by reinterpreting its bit.
This function must be used with caution. Using clock signals as part of logic expressions may lead to unexpected issues depending on the target.
pub fn as_uint(self) -> uint<1>
Casts a bool to an unsigned 1-bit integer by reinterpreting its bits.
Examples
assert false.as_uint() == 0u1;
assert true.as_uint() == 1u1;pub unsafe fn to_clock(self) -> clock
Casts a bool to a clock signal by reinterpreting its bit.
This function must be used with caution. Using clock signals as part of logic expressions may lead to unexpected issues depending on the target.
pub fn to_uint(self) -> uint<1>
Casts a bool to an unsigned 1-bit integer by reinterpreting its bits.
Examples
assert false.as_uint() == 0u1;
assert true.as_uint() == 1u1;