pub trait UBitint: Copy + Debug + Display + Hash + Eq + Ord + BitAnd<Output = Self> + BitAndAssign + BitOr<Output = Self> + BitOrAssign + BitXor<Output = Self> + BitXorAssign + TryFrom<Self::Primitive> + Into<Self::Primitive> + Num + NumAssignOps + Sized + Sealed {
type Primitive: From<Self> + TryInto<Self>;
const BITS: u32;
const MASK: Self::Primitive;
const MIN: Self;
const MAX: Self;
const ZERO: Self;
const ONE: Self;
// Required methods
fn new(value: Self::Primitive) -> Option<Self>;
fn new_masked(value: Self::Primitive) -> Self;
unsafe fn new_unchecked(value: Self::Primitive) -> Self;
fn is_in_range(value: Self::Primitive) -> bool;
}Expand description
Unsigned bitint types.
There is one type implementing UBitint for each bit width from 1 to 128
inclusive.
Required Associated Types§
Required Associated Constants§
Required Methods§
sourcefn new(value: Self::Primitive) -> Option<Self>
fn new(value: Self::Primitive) -> Option<Self>
Creates an unsigned bitint value from a primitive value if it is in
range for this type, as determined by
is_in_range.
sourcefn new_masked(value: Self::Primitive) -> Self
fn new_masked(value: Self::Primitive) -> Self
Creates an unsigned bitint value by masking off the upper bits of a
primitive value.
This conversion is lossless if the value is in range for this type, as
determined by is_in_range.
sourceunsafe fn new_unchecked(value: Self::Primitive) -> Self
unsafe fn new_unchecked(value: Self::Primitive) -> Self
Creates an unsigned bitint value from a primitive value without
checking whether it is in range for this type.
This is a zero-cost conversion.
Safety
The value must be in range for this type, as determined by
is_in_range.
sourcefn is_in_range(value: Self::Primitive) -> bool
fn is_in_range(value: Self::Primitive) -> bool
Checks whether a primitive value is in range for this type.
There are a few equivalent ways to express this check.