pub trait BitOps {
Show 15 methods
// Required methods
fn bits_precision(&self) -> u32;
fn bytes_precision(&self) -> usize;
fn bit(&self, index: u32) -> Choice;
fn set_bit(&mut self, index: u32, bit_value: Choice);
fn trailing_zeros(&self) -> u32;
fn trailing_ones(&self) -> u32;
fn leading_zeros(&self) -> u32;
fn bit_vartime(&self, index: u32) -> bool;
fn set_bit_vartime(&mut self, index: u32, bit_value: bool);
// Provided methods
fn log2_bits(&self) -> u32 { ... }
fn bits(&self) -> u32 { ... }
fn bits_vartime(&self) -> u32 { ... }
fn leading_zeros_vartime(&self) -> u32 { ... }
fn trailing_zeros_vartime(&self) -> u32 { ... }
fn trailing_ones_vartime(&self) -> u32 { ... }
}Expand description
Bit counting and bit operations.
Required Methods§
Sourcefn bits_precision(&self) -> u32
fn bits_precision(&self) -> u32
Precision of this integer in bits.
Sourcefn bytes_precision(&self) -> usize
fn bytes_precision(&self) -> usize
Precision of this integer in bytes.
Sourcefn bit(&self, index: u32) -> Choice
fn bit(&self, index: u32) -> Choice
Get the value of the bit at position index, as a truthy or falsy Choice.
Returns the falsy value for indices out of range.
Sourcefn set_bit(&mut self, index: u32, bit_value: Choice)
fn set_bit(&mut self, index: u32, bit_value: Choice)
Sets the bit at index to 0 or 1 depending on the value of bit_value.
Sourcefn trailing_zeros(&self) -> u32
fn trailing_zeros(&self) -> u32
Calculate the number of trailing zeros in the binary representation of this number.
Sourcefn trailing_ones(&self) -> u32
fn trailing_ones(&self) -> u32
Calculate the number of trailing ones in the binary representation of this number.
Sourcefn leading_zeros(&self) -> u32
fn leading_zeros(&self) -> u32
Calculate the number of leading zeros in the binary representation of this number.
Sourcefn bit_vartime(&self, index: u32) -> bool
fn bit_vartime(&self, index: u32) -> bool
Returns true if the bit at position index is set, false otherwise.
§Remarks
This operation is variable time with respect to index only.
Sourcefn set_bit_vartime(&mut self, index: u32, bit_value: bool)
fn set_bit_vartime(&mut self, index: u32, bit_value: bool)
Sets the bit at index to 0 or 1 depending on the value of bit_value,
variable time in self.
Provided Methods§
Sourcefn bits_vartime(&self) -> u32
fn bits_vartime(&self) -> u32
Calculate the number of bits required to represent a given number in variable-time with
respect to self.
Sourcefn leading_zeros_vartime(&self) -> u32
fn leading_zeros_vartime(&self) -> u32
Calculate the number of leading zeros in the binary representation of this number.
Sourcefn trailing_zeros_vartime(&self) -> u32
fn trailing_zeros_vartime(&self) -> u32
Calculate the number of trailing zeros in the binary representation of this number in
variable-time with respect to self.
Sourcefn trailing_ones_vartime(&self) -> u32
fn trailing_ones_vartime(&self) -> u32
Calculate the number of trailing ones in the binary representation of this number,
variable time in self.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".