pub trait BitWidth: Sized {
// Required method
fn bit_width(self) -> u32;
}Expand description
Computes the minimal number of bits required to represent an unsigned value.
Required Methods§
Sourcefn bit_width(self) -> u32
fn bit_width(self) -> u32
Returns the minimum number of bits required to represent self,
i.e. BITS - leading_zeros. Returns 0 for 0. Like std, this is only
provided for unsigned types.
use const_num_traits::BitWidth;
assert_eq!(BitWidth::bit_width(0u8), 0);
assert_eq!(BitWidth::bit_width(0b0101_0000u8), 7);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".