pub struct UInt<T: UnsignedInteger + BuiltinInteger, const BITS: usize> { /* private fields */ }
Implementations§
Source§impl<T: UnsignedInteger + BuiltinInteger, const BITS: usize> UInt<T, BITS>
impl<T: UnsignedInteger + BuiltinInteger, const BITS: usize> UInt<T, BITS>
pub const BITS: usize = BITS
Sourcepub const unsafe fn new_unchecked(value: T) -> Self
pub const unsafe fn new_unchecked(value: T) -> Self
Source§impl<const BITS: usize> UInt<u8, BITS>
impl<const BITS: usize> UInt<u8, BITS>
Sourcepub const fn new(value: u8) -> Self
pub const fn new(value: u8) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u8(value: u8) -> Self
pub const fn from_u8(value: u8) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u16(value: u16) -> Self
pub const fn from_u16(value: u16) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u32(value: u32) -> Self
pub const fn from_u32(value: u32) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u64(value: u64) -> Self
pub const fn from_u64(value: u64) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u128(value: u128) -> Self
pub const fn from_u128(value: u128) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn try_new(value: u8) -> Result<Self, TryNewError>
pub const fn try_new(value: u8) -> Result<Self, TryNewError>
Creates an instance or an error if the given value is outside of the valid range
pub const fn extract(value: u8, start_bit: usize) -> Self
Sourcepub const fn extract_u8(value: u8, start_bit: usize) -> Self
pub const fn extract_u8(value: u8, start_bit: usize) -> Self
Sourcepub const fn extract_i8(value: i8, start_bit: usize) -> Self
pub const fn extract_i8(value: i8, start_bit: usize) -> Self
Sourcepub const fn extract_u16(value: u16, start_bit: usize) -> Self
pub const fn extract_u16(value: u16, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u16, i.e. it is greater than 16.
Sourcepub const fn extract_i16(value: i16, start_bit: usize) -> Self
pub const fn extract_i16(value: i16, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i16, i.e. it is greater than 16.
Sourcepub const fn extract_u32(value: u32, start_bit: usize) -> Self
pub const fn extract_u32(value: u32, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u32, i.e. it is greater than 32.
Sourcepub const fn extract_i32(value: i32, start_bit: usize) -> Self
pub const fn extract_i32(value: i32, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i32, i.e. it is greater than 32.
Sourcepub const fn extract_u64(value: u64, start_bit: usize) -> Self
pub const fn extract_u64(value: u64, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u64, i.e. it is greater than 64.
Sourcepub const fn extract_i64(value: i64, start_bit: usize) -> Self
pub const fn extract_i64(value: i64, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i64, i.e. it is greater than 64.
Sourcepub const fn extract_u128(value: u128, start_bit: usize) -> Self
pub const fn extract_u128(value: u128, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u128, i.e. it is greater than 128.
Sourcepub const fn extract_i128(value: i128, start_bit: usize) -> Self
pub const fn extract_i128(value: i128, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i128, i.e. it is greater than 128.
Sourcepub const fn widen<const BITS_RESULT: usize>(self) -> UInt<u8, BITS_RESULT>
pub const fn widen<const BITS_RESULT: usize>(self) -> UInt<u8, BITS_RESULT>
Returns a UInt
with a wider bit depth but with the same base data type
Sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping (modular) addition. Computes self + rhs
, wrapping around at the
boundary of the type.
§Examples
Basic usage:
assert_eq!(u14::new(200).wrapping_add(u14::new(55)), u14::new(255));
assert_eq!(u14::new(200).wrapping_add(u14::MAX), u14::new(199));
Sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping (modular) subtraction. Computes self - rhs
, wrapping around at the
boundary of the type.
§Examples
Basic usage:
assert_eq!(u14::new(100).wrapping_sub(u14::new(100)), u14::new(0));
assert_eq!(u14::new(100).wrapping_sub(u14::MAX), u14::new(101));
Sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Wrapping (modular) multiplication. Computes self * rhs
, wrapping around at the
boundary of the type.
§Examples
Basic usage:
assert_eq!(u7::new(10).wrapping_mul(u7::new(12)), u7::new(120));
assert_eq!(u7::new(25).wrapping_mul(u7::new(12)), u7::new(44));
Sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. Computes self / rhs
.
Wrapped division on unsigned types is just normal division. There’s no way wrapping could ever happen. This function exists so that all operations are accounted for in the wrapping operations.
§Panics
This function will panic if rhs
is zero.
§Examples
Basic usage:
assert_eq!(u14::new(100).wrapping_div(u14::new(10)), u14::new(10));
Sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Panic-free bitwise shift-left; yields self << mask(rhs)
, where mask
removes any high-order bits of rhs
that would cause the shift to
exceed the bitwidth of the type.
Note that this is not the same as a rotate-left; the RHS of a wrapping
shift-left is restricted to the range of the type, rather than the bits
shifted out of the LHS being returned to the other end.
A rotate_left
function exists as well, which may
be what you want instead.
§Examples
Basic usage:
assert_eq!(u14::new(1).wrapping_shl(7), u14::new(128));
assert_eq!(u14::new(1).wrapping_shl(128), u14::new(4));
Sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Panic-free bitwise shift-right; yields self >> mask(rhs)
, where mask removes any
high-order bits of rhs
that would cause the shift to exceed the bitwidth of the type.
Note that this is not the same as a rotate-right; the RHS of a wrapping shift-right is
restricted to the range of the type, rather than the bits shifted out of the LHS being
returned to the other end.
A rotate_right
function exists as well, which may be what you
want instead.
§Examples
Basic usage:
assert_eq!(u14::new(128).wrapping_shr(7), u14::new(1));
assert_eq!(u14::new(128).wrapping_shr(128), u14::new(32));
Sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
Saturating integer addition. Computes self + rhs
, saturating at the numeric
bounds instead of overflowing.
§Examples
Basic usage:
assert_eq!(u14::new(100).saturating_add(u14::new(1)), u14::new(101));
assert_eq!(u14::MAX.saturating_add(u14::new(100)), u14::MAX);
Sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
Saturating integer subtraction. Computes self - rhs
, saturating at the numeric
bounds instead of overflowing.
§Examples
Basic usage:
assert_eq!(u14::new(100).saturating_sub(u14::new(27)), u14::new(73));
assert_eq!(u14::new(13).saturating_sub(u14::new(127)), u14::new(0));
Sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
Saturating integer multiplication. Computes self * rhs
, saturating at the numeric
bounds instead of overflowing.
§Examples
Basic usage:
assert_eq!(u14::new(2).saturating_mul(u14::new(10)), u14::new(20));
assert_eq!(u14::MAX.saturating_mul(u14::new(10)), u14::MAX);
Sourcepub const fn saturating_div(self, rhs: Self) -> Self
pub const fn saturating_div(self, rhs: Self) -> Self
Sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
Saturating integer exponentiation. Computes self.pow(exp)
, saturating at the numeric
bounds instead of overflowing.
§Examples
Basic usage:
assert_eq!(u14::new(4).saturating_pow(3), u14::new(64));
assert_eq!(u14::MAX.saturating_pow(2), u14::MAX);
Sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked integer addition. Computes self + rhs
, returning None
if overflow occurred.
§Examples
Basic usage:
assert_eq!((u14::MAX - u14::new(2)).checked_add(u14::new(1)), Some(u14::MAX - u14::new(1)));
assert_eq!((u14::MAX - u14::new(2)).checked_add(u14::new(3)), None);
Sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked integer subtraction. Computes self - rhs
, returning None
if overflow occurred.
§Examples
Basic usage:
assert_eq!(u14::new(1).checked_sub(u14::new(1)), Some(u14::new(0)));
assert_eq!(u14::new(0).checked_sub(u14::new(1)), None);
Sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Checked integer multiplication. Computes self * rhs
, returning None
if overflow occurred.
§Examples
Basic usage:
assert_eq!(u14::new(5).checked_mul(u14::new(1)), Some(u14::new(5)));
assert_eq!(u14::MAX.checked_mul(u14::new(2)), None);
Sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Checked integer division. Computes self / rhs
, returning None
if rhs == 0
.
§Examples
Basic usage:
assert_eq!(u14::new(128).checked_div(u14::new(2)), Some(u14::new(64)));
assert_eq!(u14::new(1).checked_div(u14::new(0)), None);
Sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked shift left. Computes self << rhs
, returning None
if rhs
is larger than
or equal to the number of bits in self
.
§Examples
Basic usage:
assert_eq!(u14::new(0x1).checked_shl(4), Some(u14::new(0x10)));
assert_eq!(u14::new(0x10).checked_shl(129), None);
assert_eq!(u14::new(0x10).checked_shl(13), Some(u14::new(0)));
Sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Checked shift right. Computes self >> rhs
, returning None
if rhs
is larger than
or equal to the number of bits in self
.
§Examples
Basic usage:
assert_eq!(u14::new(0x10).checked_shr(4), Some(u14::new(0x1)));
assert_eq!(u14::new(0x10).checked_shr(129), None);
Sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
.
Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_add(u14::new(2)), (u14::new(7), false));
assert_eq!(u14::MAX.overflowing_add(u14::new(1)), (u14::new(0), true));
Sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
.
Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_sub(u14::new(2)), (u14::new(3), false));
assert_eq!(u14::new(0).overflowing_sub(u14::new(1)), (u14::MAX, true));
Sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates the multiplication of self
and rhs
.
Returns a tuple of the multiplication along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_mul(u14::new(2)), (u14::new(10), false));
assert_eq!(u14::new(1_000).overflowing_mul(u14::new(1000)), (u14::new(576), true));
Sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates the divisor when self
is divided by rhs
.
Returns a tuple of the divisor along with a boolean indicating whether an arithmetic overflow would occur. Note that for unsigned integers overflow never occurs, so the second value is always false.
§Panics
This function will panic if rhs
is zero
.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_div(u14::new(2)), (u14::new(2), false));
Sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Shifts self
left by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating whether
the shift value was larger than or equal to the number of bits. If the shift value is too
large, then value is masked (N-1
) where N
is the number of bits, and this value is then
used to perform the shift.
§Examples
Basic usage:
assert_eq!(u14::new(0x1).overflowing_shl(4), (u14::new(0x10), false));
assert_eq!(u14::new(0x1).overflowing_shl(132), (u14::new(0x40), true));
assert_eq!(u14::new(0x10).overflowing_shl(13), (u14::new(0), false));
Sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Shifts self
right by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating whether
the shift value was larger than or equal to the number of bits. If the shift value is too
large, then value is masked (N-1
) where N
is the number of bits, and this value is then
used to perform the shift.
§Examples
Basic usage:
assert_eq!(u14::new(0x10).overflowing_shr(4), (u14::new(0x1), false));
assert_eq!(u14::new(0x10).overflowing_shr(113), (u14::new(0x8), true));
Sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of bits in the integer. The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc.
§Examples
Basic usage:
assert_eq!(u6::new(0b10_1010).reverse_bits(), u6::new(0b01_0101));
assert_eq!(u6::new(0), u6::new(0).reverse_bits());
Sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation of self
.
§Examples
Basic usage:
let n = u7::new(0b100_1100);
assert_eq!(n.count_ones(), 3);
let max = u7::MAX;
assert_eq!(max.count_ones(), 7);
let zero = u7::new(0);
assert_eq!(zero.count_ones(), 0);
Sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representation of self
.
§Examples
Basic usage:
let zero = u7::new(0);
assert_eq!(zero.count_zeros(), 7);
let max = u7::MAX;
assert_eq!(max.count_zeros(), 0);
Sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation of self
.
§Examples
Basic usage:
let n = !(u7::MAX >> 2);
assert_eq!(n.leading_ones(), 2);
let zero = u7::new(0);
assert_eq!(zero.leading_ones(), 0);
let max = u7::MAX;
assert_eq!(max.leading_ones(), 7);
Sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary representation of self
.
§Examples
Basic usage:
let n = u7::MAX >> 2;
assert_eq!(n.leading_zeros(), 2);
let zero = u7::new(0);
assert_eq!(zero.leading_zeros(), 7);
let max = u7::MAX;
assert_eq!(max.leading_zeros(), 0);
Sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation of self
.
§Examples
Basic usage:
let n = u7::new(0b1010111);
assert_eq!(n.trailing_ones(), 3);
let zero = u7::new(0);
assert_eq!(zero.trailing_ones(), 0);
let max = u7::MAX;
assert_eq!(max.trailing_ones(), 7);
Sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representation of self
.
§Examples
Basic usage:
let n = u7::new(0b010_1000);
assert_eq!(n.trailing_zeros(), 3);
let zero = u7::new(0);
assert_eq!(zero.trailing_zeros(), 7);
let max = u7::MAX;
assert_eq!(max.trailing_zeros(), 0);
Sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Shifts the bits to the left by a specified amount, n
, wrapping the truncated bits
to the end of the resulting integer.
Please note this isn’t the same operation as the <<
shifting operator!
§Examples
Basic usage:
let n = u6::new(0b10_1010);
let m = u6::new(0b01_0101);
assert_eq!(n.rotate_left(1), m);
Sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Shifts the bits to the right by a specified amount, n
, wrapping the truncated bits
to the beginning of the resulting integer.
Please note this isn’t the same operation as the >>
shifting operator!
§Examples
Basic usage:
let n = u6::new(0b10_1010);
let m = u6::new(0b01_0101);
assert_eq!(n.rotate_right(1), m);
Source§impl<const BITS: usize> UInt<u16, BITS>
impl<const BITS: usize> UInt<u16, BITS>
Sourcepub const fn new(value: u16) -> Self
pub const fn new(value: u16) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u8(value: u8) -> Self
pub const fn from_u8(value: u8) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u16(value: u16) -> Self
pub const fn from_u16(value: u16) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u32(value: u32) -> Self
pub const fn from_u32(value: u32) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u64(value: u64) -> Self
pub const fn from_u64(value: u64) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u128(value: u128) -> Self
pub const fn from_u128(value: u128) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn try_new(value: u16) -> Result<Self, TryNewError>
pub const fn try_new(value: u16) -> Result<Self, TryNewError>
Creates an instance or an error if the given value is outside of the valid range
pub const fn extract(value: u16, start_bit: usize) -> Self
Sourcepub const fn extract_u8(value: u8, start_bit: usize) -> Self
pub const fn extract_u8(value: u8, start_bit: usize) -> Self
Sourcepub const fn extract_i8(value: i8, start_bit: usize) -> Self
pub const fn extract_i8(value: i8, start_bit: usize) -> Self
Sourcepub const fn extract_u16(value: u16, start_bit: usize) -> Self
pub const fn extract_u16(value: u16, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u16, i.e. it is greater than 16.
Sourcepub const fn extract_i16(value: i16, start_bit: usize) -> Self
pub const fn extract_i16(value: i16, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i16, i.e. it is greater than 16.
Sourcepub const fn extract_u32(value: u32, start_bit: usize) -> Self
pub const fn extract_u32(value: u32, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u32, i.e. it is greater than 32.
Sourcepub const fn extract_i32(value: i32, start_bit: usize) -> Self
pub const fn extract_i32(value: i32, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i32, i.e. it is greater than 32.
Sourcepub const fn extract_u64(value: u64, start_bit: usize) -> Self
pub const fn extract_u64(value: u64, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u64, i.e. it is greater than 64.
Sourcepub const fn extract_i64(value: i64, start_bit: usize) -> Self
pub const fn extract_i64(value: i64, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i64, i.e. it is greater than 64.
Sourcepub const fn extract_u128(value: u128, start_bit: usize) -> Self
pub const fn extract_u128(value: u128, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u128, i.e. it is greater than 128.
Sourcepub const fn extract_i128(value: i128, start_bit: usize) -> Self
pub const fn extract_i128(value: i128, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i128, i.e. it is greater than 128.
Sourcepub const fn widen<const BITS_RESULT: usize>(self) -> UInt<u16, BITS_RESULT>
pub const fn widen<const BITS_RESULT: usize>(self) -> UInt<u16, BITS_RESULT>
Returns a UInt
with a wider bit depth but with the same base data type
Sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. Computes self / rhs
.
Wrapped division on unsigned types is just normal division. There’s no way wrapping could ever happen. This function exists so that all operations are accounted for in the wrapping operations.
§Panics
This function will panic if rhs
is zero.
§Examples
Basic usage:
assert_eq!(u14::new(100).wrapping_div(u14::new(10)), u14::new(10));
Sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Panic-free bitwise shift-left; yields self << mask(rhs)
, where mask
removes any high-order bits of rhs
that would cause the shift to
exceed the bitwidth of the type.
Note that this is not the same as a rotate-left; the RHS of a wrapping
shift-left is restricted to the range of the type, rather than the bits
shifted out of the LHS being returned to the other end.
A rotate_left
function exists as well, which may
be what you want instead.
§Examples
Basic usage:
assert_eq!(u14::new(1).wrapping_shl(7), u14::new(128));
assert_eq!(u14::new(1).wrapping_shl(128), u14::new(4));
Sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Panic-free bitwise shift-right; yields self >> mask(rhs)
, where mask removes any
high-order bits of rhs
that would cause the shift to exceed the bitwidth of the type.
Note that this is not the same as a rotate-right; the RHS of a wrapping shift-right is
restricted to the range of the type, rather than the bits shifted out of the LHS being
returned to the other end.
A rotate_right
function exists as well, which may be what you
want instead.
§Examples
Basic usage:
assert_eq!(u14::new(128).wrapping_shr(7), u14::new(1));
assert_eq!(u14::new(128).wrapping_shr(128), u14::new(32));
Sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
Sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
Sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
Sourcepub const fn saturating_div(self, rhs: Self) -> Self
pub const fn saturating_div(self, rhs: Self) -> Self
Sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
Sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked shift left. Computes self << rhs
, returning None
if rhs
is larger than
or equal to the number of bits in self
.
§Examples
Basic usage:
assert_eq!(u14::new(0x1).checked_shl(4), Some(u14::new(0x10)));
assert_eq!(u14::new(0x10).checked_shl(129), None);
assert_eq!(u14::new(0x10).checked_shl(13), Some(u14::new(0)));
Sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
.
Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_add(u14::new(2)), (u14::new(7), false));
assert_eq!(u14::MAX.overflowing_add(u14::new(1)), (u14::new(0), true));
Sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
.
Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_sub(u14::new(2)), (u14::new(3), false));
assert_eq!(u14::new(0).overflowing_sub(u14::new(1)), (u14::MAX, true));
Sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates the multiplication of self
and rhs
.
Returns a tuple of the multiplication along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_mul(u14::new(2)), (u14::new(10), false));
assert_eq!(u14::new(1_000).overflowing_mul(u14::new(1000)), (u14::new(576), true));
Sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates the divisor when self
is divided by rhs
.
Returns a tuple of the divisor along with a boolean indicating whether an arithmetic overflow would occur. Note that for unsigned integers overflow never occurs, so the second value is always false.
§Panics
This function will panic if rhs
is zero
.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_div(u14::new(2)), (u14::new(2), false));
Sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Shifts self
left by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating whether
the shift value was larger than or equal to the number of bits. If the shift value is too
large, then value is masked (N-1
) where N
is the number of bits, and this value is then
used to perform the shift.
§Examples
Basic usage:
assert_eq!(u14::new(0x1).overflowing_shl(4), (u14::new(0x10), false));
assert_eq!(u14::new(0x1).overflowing_shl(132), (u14::new(0x40), true));
assert_eq!(u14::new(0x10).overflowing_shl(13), (u14::new(0), false));
Sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Shifts self
right by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating whether
the shift value was larger than or equal to the number of bits. If the shift value is too
large, then value is masked (N-1
) where N
is the number of bits, and this value is then
used to perform the shift.
§Examples
Basic usage:
assert_eq!(u14::new(0x10).overflowing_shr(4), (u14::new(0x1), false));
assert_eq!(u14::new(0x10).overflowing_shr(113), (u14::new(0x8), true));
Sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of bits in the integer. The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc.
§Examples
Basic usage:
assert_eq!(u6::new(0b10_1010).reverse_bits(), u6::new(0b01_0101));
assert_eq!(u6::new(0), u6::new(0).reverse_bits());
Sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Shifts the bits to the left by a specified amount, n
, wrapping the truncated bits
to the end of the resulting integer.
Please note this isn’t the same operation as the <<
shifting operator!
§Examples
Basic usage:
let n = u6::new(0b10_1010);
let m = u6::new(0b01_0101);
assert_eq!(n.rotate_left(1), m);
Sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Shifts the bits to the right by a specified amount, n
, wrapping the truncated bits
to the beginning of the resulting integer.
Please note this isn’t the same operation as the >>
shifting operator!
§Examples
Basic usage:
let n = u6::new(0b10_1010);
let m = u6::new(0b01_0101);
assert_eq!(n.rotate_right(1), m);
Source§impl<const BITS: usize> UInt<u32, BITS>
impl<const BITS: usize> UInt<u32, BITS>
Sourcepub const fn new(value: u32) -> Self
pub const fn new(value: u32) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u8(value: u8) -> Self
pub const fn from_u8(value: u8) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u16(value: u16) -> Self
pub const fn from_u16(value: u16) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u32(value: u32) -> Self
pub const fn from_u32(value: u32) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u64(value: u64) -> Self
pub const fn from_u64(value: u64) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u128(value: u128) -> Self
pub const fn from_u128(value: u128) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn try_new(value: u32) -> Result<Self, TryNewError>
pub const fn try_new(value: u32) -> Result<Self, TryNewError>
Creates an instance or an error if the given value is outside of the valid range
pub const fn extract(value: u32, start_bit: usize) -> Self
Sourcepub const fn extract_u8(value: u8, start_bit: usize) -> Self
pub const fn extract_u8(value: u8, start_bit: usize) -> Self
Sourcepub const fn extract_i8(value: i8, start_bit: usize) -> Self
pub const fn extract_i8(value: i8, start_bit: usize) -> Self
Sourcepub const fn extract_u16(value: u16, start_bit: usize) -> Self
pub const fn extract_u16(value: u16, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u16, i.e. it is greater than 16.
Sourcepub const fn extract_i16(value: i16, start_bit: usize) -> Self
pub const fn extract_i16(value: i16, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i16, i.e. it is greater than 16.
Sourcepub const fn extract_u32(value: u32, start_bit: usize) -> Self
pub const fn extract_u32(value: u32, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u32, i.e. it is greater than 32.
Sourcepub const fn extract_i32(value: i32, start_bit: usize) -> Self
pub const fn extract_i32(value: i32, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i32, i.e. it is greater than 32.
Sourcepub const fn extract_u64(value: u64, start_bit: usize) -> Self
pub const fn extract_u64(value: u64, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u64, i.e. it is greater than 64.
Sourcepub const fn extract_i64(value: i64, start_bit: usize) -> Self
pub const fn extract_i64(value: i64, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i64, i.e. it is greater than 64.
Sourcepub const fn extract_u128(value: u128, start_bit: usize) -> Self
pub const fn extract_u128(value: u128, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u128, i.e. it is greater than 128.
Sourcepub const fn extract_i128(value: i128, start_bit: usize) -> Self
pub const fn extract_i128(value: i128, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i128, i.e. it is greater than 128.
Sourcepub const fn widen<const BITS_RESULT: usize>(self) -> UInt<u32, BITS_RESULT>
pub const fn widen<const BITS_RESULT: usize>(self) -> UInt<u32, BITS_RESULT>
Returns a UInt
with a wider bit depth but with the same base data type
Sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. Computes self / rhs
.
Wrapped division on unsigned types is just normal division. There’s no way wrapping could ever happen. This function exists so that all operations are accounted for in the wrapping operations.
§Panics
This function will panic if rhs
is zero.
§Examples
Basic usage:
assert_eq!(u14::new(100).wrapping_div(u14::new(10)), u14::new(10));
Sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Panic-free bitwise shift-left; yields self << mask(rhs)
, where mask
removes any high-order bits of rhs
that would cause the shift to
exceed the bitwidth of the type.
Note that this is not the same as a rotate-left; the RHS of a wrapping
shift-left is restricted to the range of the type, rather than the bits
shifted out of the LHS being returned to the other end.
A rotate_left
function exists as well, which may
be what you want instead.
§Examples
Basic usage:
assert_eq!(u14::new(1).wrapping_shl(7), u14::new(128));
assert_eq!(u14::new(1).wrapping_shl(128), u14::new(4));
Sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Panic-free bitwise shift-right; yields self >> mask(rhs)
, where mask removes any
high-order bits of rhs
that would cause the shift to exceed the bitwidth of the type.
Note that this is not the same as a rotate-right; the RHS of a wrapping shift-right is
restricted to the range of the type, rather than the bits shifted out of the LHS being
returned to the other end.
A rotate_right
function exists as well, which may be what you
want instead.
§Examples
Basic usage:
assert_eq!(u14::new(128).wrapping_shr(7), u14::new(1));
assert_eq!(u14::new(128).wrapping_shr(128), u14::new(32));
Sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
Sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
Sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
Sourcepub const fn saturating_div(self, rhs: Self) -> Self
pub const fn saturating_div(self, rhs: Self) -> Self
Sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
Sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked shift left. Computes self << rhs
, returning None
if rhs
is larger than
or equal to the number of bits in self
.
§Examples
Basic usage:
assert_eq!(u14::new(0x1).checked_shl(4), Some(u14::new(0x10)));
assert_eq!(u14::new(0x10).checked_shl(129), None);
assert_eq!(u14::new(0x10).checked_shl(13), Some(u14::new(0)));
Sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
.
Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_add(u14::new(2)), (u14::new(7), false));
assert_eq!(u14::MAX.overflowing_add(u14::new(1)), (u14::new(0), true));
Sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
.
Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_sub(u14::new(2)), (u14::new(3), false));
assert_eq!(u14::new(0).overflowing_sub(u14::new(1)), (u14::MAX, true));
Sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates the multiplication of self
and rhs
.
Returns a tuple of the multiplication along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_mul(u14::new(2)), (u14::new(10), false));
assert_eq!(u14::new(1_000).overflowing_mul(u14::new(1000)), (u14::new(576), true));
Sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates the divisor when self
is divided by rhs
.
Returns a tuple of the divisor along with a boolean indicating whether an arithmetic overflow would occur. Note that for unsigned integers overflow never occurs, so the second value is always false.
§Panics
This function will panic if rhs
is zero
.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_div(u14::new(2)), (u14::new(2), false));
Sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Shifts self
left by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating whether
the shift value was larger than or equal to the number of bits. If the shift value is too
large, then value is masked (N-1
) where N
is the number of bits, and this value is then
used to perform the shift.
§Examples
Basic usage:
assert_eq!(u14::new(0x1).overflowing_shl(4), (u14::new(0x10), false));
assert_eq!(u14::new(0x1).overflowing_shl(132), (u14::new(0x40), true));
assert_eq!(u14::new(0x10).overflowing_shl(13), (u14::new(0), false));
Sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Shifts self
right by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating whether
the shift value was larger than or equal to the number of bits. If the shift value is too
large, then value is masked (N-1
) where N
is the number of bits, and this value is then
used to perform the shift.
§Examples
Basic usage:
assert_eq!(u14::new(0x10).overflowing_shr(4), (u14::new(0x1), false));
assert_eq!(u14::new(0x10).overflowing_shr(113), (u14::new(0x8), true));
Sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of bits in the integer. The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc.
§Examples
Basic usage:
assert_eq!(u6::new(0b10_1010).reverse_bits(), u6::new(0b01_0101));
assert_eq!(u6::new(0), u6::new(0).reverse_bits());
Sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Shifts the bits to the left by a specified amount, n
, wrapping the truncated bits
to the end of the resulting integer.
Please note this isn’t the same operation as the <<
shifting operator!
§Examples
Basic usage:
let n = u6::new(0b10_1010);
let m = u6::new(0b01_0101);
assert_eq!(n.rotate_left(1), m);
Sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Shifts the bits to the right by a specified amount, n
, wrapping the truncated bits
to the beginning of the resulting integer.
Please note this isn’t the same operation as the >>
shifting operator!
§Examples
Basic usage:
let n = u6::new(0b10_1010);
let m = u6::new(0b01_0101);
assert_eq!(n.rotate_right(1), m);
Source§impl<const BITS: usize> UInt<u64, BITS>
impl<const BITS: usize> UInt<u64, BITS>
Sourcepub const fn new(value: u64) -> Self
pub const fn new(value: u64) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u8(value: u8) -> Self
pub const fn from_u8(value: u8) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u16(value: u16) -> Self
pub const fn from_u16(value: u16) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u32(value: u32) -> Self
pub const fn from_u32(value: u32) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u64(value: u64) -> Self
pub const fn from_u64(value: u64) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u128(value: u128) -> Self
pub const fn from_u128(value: u128) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn try_new(value: u64) -> Result<Self, TryNewError>
pub const fn try_new(value: u64) -> Result<Self, TryNewError>
Creates an instance or an error if the given value is outside of the valid range
pub const fn extract(value: u64, start_bit: usize) -> Self
Sourcepub const fn extract_u8(value: u8, start_bit: usize) -> Self
pub const fn extract_u8(value: u8, start_bit: usize) -> Self
Sourcepub const fn extract_i8(value: i8, start_bit: usize) -> Self
pub const fn extract_i8(value: i8, start_bit: usize) -> Self
Sourcepub const fn extract_u16(value: u16, start_bit: usize) -> Self
pub const fn extract_u16(value: u16, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u16, i.e. it is greater than 16.
Sourcepub const fn extract_i16(value: i16, start_bit: usize) -> Self
pub const fn extract_i16(value: i16, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i16, i.e. it is greater than 16.
Sourcepub const fn extract_u32(value: u32, start_bit: usize) -> Self
pub const fn extract_u32(value: u32, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u32, i.e. it is greater than 32.
Sourcepub const fn extract_i32(value: i32, start_bit: usize) -> Self
pub const fn extract_i32(value: i32, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i32, i.e. it is greater than 32.
Sourcepub const fn extract_u64(value: u64, start_bit: usize) -> Self
pub const fn extract_u64(value: u64, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u64, i.e. it is greater than 64.
Sourcepub const fn extract_i64(value: i64, start_bit: usize) -> Self
pub const fn extract_i64(value: i64, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i64, i.e. it is greater than 64.
Sourcepub const fn extract_u128(value: u128, start_bit: usize) -> Self
pub const fn extract_u128(value: u128, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u128, i.e. it is greater than 128.
Sourcepub const fn extract_i128(value: i128, start_bit: usize) -> Self
pub const fn extract_i128(value: i128, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i128, i.e. it is greater than 128.
Sourcepub const fn widen<const BITS_RESULT: usize>(self) -> UInt<u64, BITS_RESULT>
pub const fn widen<const BITS_RESULT: usize>(self) -> UInt<u64, BITS_RESULT>
Returns a UInt
with a wider bit depth but with the same base data type
Sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. Computes self / rhs
.
Wrapped division on unsigned types is just normal division. There’s no way wrapping could ever happen. This function exists so that all operations are accounted for in the wrapping operations.
§Panics
This function will panic if rhs
is zero.
§Examples
Basic usage:
assert_eq!(u14::new(100).wrapping_div(u14::new(10)), u14::new(10));
Sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Panic-free bitwise shift-left; yields self << mask(rhs)
, where mask
removes any high-order bits of rhs
that would cause the shift to
exceed the bitwidth of the type.
Note that this is not the same as a rotate-left; the RHS of a wrapping
shift-left is restricted to the range of the type, rather than the bits
shifted out of the LHS being returned to the other end.
A rotate_left
function exists as well, which may
be what you want instead.
§Examples
Basic usage:
assert_eq!(u14::new(1).wrapping_shl(7), u14::new(128));
assert_eq!(u14::new(1).wrapping_shl(128), u14::new(4));
Sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Panic-free bitwise shift-right; yields self >> mask(rhs)
, where mask removes any
high-order bits of rhs
that would cause the shift to exceed the bitwidth of the type.
Note that this is not the same as a rotate-right; the RHS of a wrapping shift-right is
restricted to the range of the type, rather than the bits shifted out of the LHS being
returned to the other end.
A rotate_right
function exists as well, which may be what you
want instead.
§Examples
Basic usage:
assert_eq!(u14::new(128).wrapping_shr(7), u14::new(1));
assert_eq!(u14::new(128).wrapping_shr(128), u14::new(32));
Sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
Sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
Sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
Sourcepub const fn saturating_div(self, rhs: Self) -> Self
pub const fn saturating_div(self, rhs: Self) -> Self
Sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
Sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked shift left. Computes self << rhs
, returning None
if rhs
is larger than
or equal to the number of bits in self
.
§Examples
Basic usage:
assert_eq!(u14::new(0x1).checked_shl(4), Some(u14::new(0x10)));
assert_eq!(u14::new(0x10).checked_shl(129), None);
assert_eq!(u14::new(0x10).checked_shl(13), Some(u14::new(0)));
Sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
.
Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_add(u14::new(2)), (u14::new(7), false));
assert_eq!(u14::MAX.overflowing_add(u14::new(1)), (u14::new(0), true));
Sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
.
Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_sub(u14::new(2)), (u14::new(3), false));
assert_eq!(u14::new(0).overflowing_sub(u14::new(1)), (u14::MAX, true));
Sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates the multiplication of self
and rhs
.
Returns a tuple of the multiplication along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_mul(u14::new(2)), (u14::new(10), false));
assert_eq!(u14::new(1_000).overflowing_mul(u14::new(1000)), (u14::new(576), true));
Sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates the divisor when self
is divided by rhs
.
Returns a tuple of the divisor along with a boolean indicating whether an arithmetic overflow would occur. Note that for unsigned integers overflow never occurs, so the second value is always false.
§Panics
This function will panic if rhs
is zero
.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_div(u14::new(2)), (u14::new(2), false));
Sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Shifts self
left by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating whether
the shift value was larger than or equal to the number of bits. If the shift value is too
large, then value is masked (N-1
) where N
is the number of bits, and this value is then
used to perform the shift.
§Examples
Basic usage:
assert_eq!(u14::new(0x1).overflowing_shl(4), (u14::new(0x10), false));
assert_eq!(u14::new(0x1).overflowing_shl(132), (u14::new(0x40), true));
assert_eq!(u14::new(0x10).overflowing_shl(13), (u14::new(0), false));
Sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Shifts self
right by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating whether
the shift value was larger than or equal to the number of bits. If the shift value is too
large, then value is masked (N-1
) where N
is the number of bits, and this value is then
used to perform the shift.
§Examples
Basic usage:
assert_eq!(u14::new(0x10).overflowing_shr(4), (u14::new(0x1), false));
assert_eq!(u14::new(0x10).overflowing_shr(113), (u14::new(0x8), true));
Sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of bits in the integer. The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc.
§Examples
Basic usage:
assert_eq!(u6::new(0b10_1010).reverse_bits(), u6::new(0b01_0101));
assert_eq!(u6::new(0), u6::new(0).reverse_bits());
Sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Shifts the bits to the left by a specified amount, n
, wrapping the truncated bits
to the end of the resulting integer.
Please note this isn’t the same operation as the <<
shifting operator!
§Examples
Basic usage:
let n = u6::new(0b10_1010);
let m = u6::new(0b01_0101);
assert_eq!(n.rotate_left(1), m);
Sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Shifts the bits to the right by a specified amount, n
, wrapping the truncated bits
to the beginning of the resulting integer.
Please note this isn’t the same operation as the >>
shifting operator!
§Examples
Basic usage:
let n = u6::new(0b10_1010);
let m = u6::new(0b01_0101);
assert_eq!(n.rotate_right(1), m);
Source§impl<const BITS: usize> UInt<u128, BITS>
impl<const BITS: usize> UInt<u128, BITS>
Sourcepub const fn new(value: u128) -> Self
pub const fn new(value: u128) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u8(value: u8) -> Self
pub const fn from_u8(value: u8) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u16(value: u16) -> Self
pub const fn from_u16(value: u16) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u32(value: u32) -> Self
pub const fn from_u32(value: u32) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u64(value: u64) -> Self
pub const fn from_u64(value: u64) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn from_u128(value: u128) -> Self
pub const fn from_u128(value: u128) -> Self
Creates an instance. Panics if the given value is outside of the valid range
Sourcepub const fn try_new(value: u128) -> Result<Self, TryNewError>
pub const fn try_new(value: u128) -> Result<Self, TryNewError>
Creates an instance or an error if the given value is outside of the valid range
pub const fn extract(value: u128, start_bit: usize) -> Self
Sourcepub const fn extract_u8(value: u8, start_bit: usize) -> Self
pub const fn extract_u8(value: u8, start_bit: usize) -> Self
Sourcepub const fn extract_i8(value: i8, start_bit: usize) -> Self
pub const fn extract_i8(value: i8, start_bit: usize) -> Self
Sourcepub const fn extract_u16(value: u16, start_bit: usize) -> Self
pub const fn extract_u16(value: u16, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u16, i.e. it is greater than 16.
Sourcepub const fn extract_i16(value: i16, start_bit: usize) -> Self
pub const fn extract_i16(value: i16, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i16, i.e. it is greater than 16.
Sourcepub const fn extract_u32(value: u32, start_bit: usize) -> Self
pub const fn extract_u32(value: u32, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u32, i.e. it is greater than 32.
Sourcepub const fn extract_i32(value: i32, start_bit: usize) -> Self
pub const fn extract_i32(value: i32, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i32, i.e. it is greater than 32.
Sourcepub const fn extract_u64(value: u64, start_bit: usize) -> Self
pub const fn extract_u64(value: u64, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u64, i.e. it is greater than 64.
Sourcepub const fn extract_i64(value: i64, start_bit: usize) -> Self
pub const fn extract_i64(value: i64, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i64, i.e. it is greater than 64.
Sourcepub const fn extract_u128(value: u128, start_bit: usize) -> Self
pub const fn extract_u128(value: u128, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an u128, i.e. it is greater than 128.
Sourcepub const fn extract_i128(value: i128, start_bit: usize) -> Self
pub const fn extract_i128(value: i128, start_bit: usize) -> Self
Extracts bits from a given value, starting from start_bit
. This is equivalent to: new((value >> start_bit) & MASK)
.
Unlike new
, this function doesn’t perform range-checking and is slightly more efficient.
§Panics
Panics if start_bit + Self::BITS
doesn’t fit within an i128, i.e. it is greater than 128.
Sourcepub const fn widen<const BITS_RESULT: usize>(self) -> UInt<u128, BITS_RESULT>
pub const fn widen<const BITS_RESULT: usize>(self) -> UInt<u128, BITS_RESULT>
Returns a UInt
with a wider bit depth but with the same base data type
Sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Sourcepub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn wrapping_mul(self, rhs: Self) -> Self
Sourcepub const fn wrapping_div(self, rhs: Self) -> Self
pub const fn wrapping_div(self, rhs: Self) -> Self
Wrapping (modular) division. Computes self / rhs
.
Wrapped division on unsigned types is just normal division. There’s no way wrapping could ever happen. This function exists so that all operations are accounted for in the wrapping operations.
§Panics
This function will panic if rhs
is zero.
§Examples
Basic usage:
assert_eq!(u14::new(100).wrapping_div(u14::new(10)), u14::new(10));
Sourcepub const fn wrapping_shl(self, rhs: u32) -> Self
pub const fn wrapping_shl(self, rhs: u32) -> Self
Panic-free bitwise shift-left; yields self << mask(rhs)
, where mask
removes any high-order bits of rhs
that would cause the shift to
exceed the bitwidth of the type.
Note that this is not the same as a rotate-left; the RHS of a wrapping
shift-left is restricted to the range of the type, rather than the bits
shifted out of the LHS being returned to the other end.
A rotate_left
function exists as well, which may
be what you want instead.
§Examples
Basic usage:
assert_eq!(u14::new(1).wrapping_shl(7), u14::new(128));
assert_eq!(u14::new(1).wrapping_shl(128), u14::new(4));
Sourcepub const fn wrapping_shr(self, rhs: u32) -> Self
pub const fn wrapping_shr(self, rhs: u32) -> Self
Panic-free bitwise shift-right; yields self >> mask(rhs)
, where mask removes any
high-order bits of rhs
that would cause the shift to exceed the bitwidth of the type.
Note that this is not the same as a rotate-right; the RHS of a wrapping shift-right is
restricted to the range of the type, rather than the bits shifted out of the LHS being
returned to the other end.
A rotate_right
function exists as well, which may be what you
want instead.
§Examples
Basic usage:
assert_eq!(u14::new(128).wrapping_shr(7), u14::new(1));
assert_eq!(u14::new(128).wrapping_shr(128), u14::new(32));
Sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
Sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
Sourcepub const fn saturating_mul(self, rhs: Self) -> Self
pub const fn saturating_mul(self, rhs: Self) -> Self
Sourcepub const fn saturating_div(self, rhs: Self) -> Self
pub const fn saturating_div(self, rhs: Self) -> Self
Sourcepub const fn saturating_pow(self, exp: u32) -> Self
pub const fn saturating_pow(self, exp: u32) -> Self
Sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_div(self, rhs: Self) -> Option<Self>
pub const fn checked_div(self, rhs: Self) -> Option<Self>
Sourcepub const fn checked_shl(self, rhs: u32) -> Option<Self>
pub const fn checked_shl(self, rhs: u32) -> Option<Self>
Checked shift left. Computes self << rhs
, returning None
if rhs
is larger than
or equal to the number of bits in self
.
§Examples
Basic usage:
assert_eq!(u14::new(0x1).checked_shl(4), Some(u14::new(0x10)));
assert_eq!(u14::new(0x10).checked_shl(129), None);
assert_eq!(u14::new(0x10).checked_shl(13), Some(u14::new(0)));
Sourcepub const fn checked_shr(self, rhs: u32) -> Option<Self>
pub const fn checked_shr(self, rhs: u32) -> Option<Self>
Sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates self + rhs
.
Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_add(u14::new(2)), (u14::new(7), false));
assert_eq!(u14::MAX.overflowing_add(u14::new(1)), (u14::new(0), true));
Sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates self - rhs
.
Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_sub(u14::new(2)), (u14::new(3), false));
assert_eq!(u14::new(0).overflowing_sub(u14::new(1)), (u14::MAX, true));
Sourcepub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Calculates the multiplication of self
and rhs
.
Returns a tuple of the multiplication along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_mul(u14::new(2)), (u14::new(10), false));
assert_eq!(u14::new(1_000).overflowing_mul(u14::new(1000)), (u14::new(576), true));
Sourcepub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool)
Calculates the divisor when self
is divided by rhs
.
Returns a tuple of the divisor along with a boolean indicating whether an arithmetic overflow would occur. Note that for unsigned integers overflow never occurs, so the second value is always false.
§Panics
This function will panic if rhs
is zero
.
§Examples
Basic usage:
assert_eq!(u14::new(5).overflowing_div(u14::new(2)), (u14::new(2), false));
Sourcepub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool)
Shifts self
left by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating whether
the shift value was larger than or equal to the number of bits. If the shift value is too
large, then value is masked (N-1
) where N
is the number of bits, and this value is then
used to perform the shift.
§Examples
Basic usage:
assert_eq!(u14::new(0x1).overflowing_shl(4), (u14::new(0x10), false));
assert_eq!(u14::new(0x1).overflowing_shl(132), (u14::new(0x40), true));
assert_eq!(u14::new(0x10).overflowing_shl(13), (u14::new(0), false));
Sourcepub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool)
Shifts self
right by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating whether
the shift value was larger than or equal to the number of bits. If the shift value is too
large, then value is masked (N-1
) where N
is the number of bits, and this value is then
used to perform the shift.
§Examples
Basic usage:
assert_eq!(u14::new(0x10).overflowing_shr(4), (u14::new(0x1), false));
assert_eq!(u14::new(0x10).overflowing_shr(113), (u14::new(0x8), true));
Sourcepub const fn reverse_bits(self) -> Self
pub const fn reverse_bits(self) -> Self
Reverses the order of bits in the integer. The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc.
§Examples
Basic usage:
assert_eq!(u6::new(0b10_1010).reverse_bits(), u6::new(0b01_0101));
assert_eq!(u6::new(0), u6::new(0).reverse_bits());
Sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Sourcepub const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Shifts the bits to the left by a specified amount, n
, wrapping the truncated bits
to the end of the resulting integer.
Please note this isn’t the same operation as the <<
shifting operator!
§Examples
Basic usage:
let n = u6::new(0b10_1010);
let m = u6::new(0b01_0101);
assert_eq!(n.rotate_left(1), m);
Sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Shifts the bits to the right by a specified amount, n
, wrapping the truncated bits
to the beginning of the resulting integer.
Please note this isn’t the same operation as the >>
shifting operator!
§Examples
Basic usage:
let n = u6::new(0b10_1010);
let m = u6::new(0b01_0101);
assert_eq!(n.rotate_right(1), m);
Source§impl UInt<u32, 24>
impl UInt<u32, 24>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 3]
pub const fn to_be_bytes(self) -> [u8; 3]
pub const fn from_le_bytes(from: [u8; 3]) -> Self
pub const fn from_be_bytes(from: [u8; 3]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 3]
pub const fn from_ne_bytes(bytes: [u8; 3]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u64, 24>
impl UInt<u64, 24>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 3]
pub const fn to_be_bytes(self) -> [u8; 3]
pub const fn from_le_bytes(from: [u8; 3]) -> Self
pub const fn from_be_bytes(from: [u8; 3]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 3]
pub const fn from_ne_bytes(bytes: [u8; 3]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u128, 24>
impl UInt<u128, 24>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 3]
pub const fn to_be_bytes(self) -> [u8; 3]
pub const fn from_le_bytes(from: [u8; 3]) -> Self
pub const fn from_be_bytes(from: [u8; 3]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 3]
pub const fn from_ne_bytes(bytes: [u8; 3]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u64, 40>
impl UInt<u64, 40>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 5]
pub const fn to_be_bytes(self) -> [u8; 5]
pub const fn from_le_bytes(from: [u8; 5]) -> Self
pub const fn from_be_bytes(from: [u8; 5]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 5]
pub const fn from_ne_bytes(bytes: [u8; 5]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u128, 40>
impl UInt<u128, 40>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 5]
pub const fn to_be_bytes(self) -> [u8; 5]
pub const fn from_le_bytes(from: [u8; 5]) -> Self
pub const fn from_be_bytes(from: [u8; 5]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 5]
pub const fn from_ne_bytes(bytes: [u8; 5]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u64, 48>
impl UInt<u64, 48>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 6]
pub const fn to_be_bytes(self) -> [u8; 6]
pub const fn from_le_bytes(from: [u8; 6]) -> Self
pub const fn from_be_bytes(from: [u8; 6]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 6]
pub const fn from_ne_bytes(bytes: [u8; 6]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u128, 48>
impl UInt<u128, 48>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 6]
pub const fn to_be_bytes(self) -> [u8; 6]
pub const fn from_le_bytes(from: [u8; 6]) -> Self
pub const fn from_be_bytes(from: [u8; 6]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 6]
pub const fn from_ne_bytes(bytes: [u8; 6]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u64, 56>
impl UInt<u64, 56>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 7]
pub const fn to_be_bytes(self) -> [u8; 7]
pub const fn from_le_bytes(from: [u8; 7]) -> Self
pub const fn from_be_bytes(from: [u8; 7]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 7]
pub const fn from_ne_bytes(bytes: [u8; 7]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u128, 56>
impl UInt<u128, 56>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 7]
pub const fn to_be_bytes(self) -> [u8; 7]
pub const fn from_le_bytes(from: [u8; 7]) -> Self
pub const fn from_be_bytes(from: [u8; 7]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 7]
pub const fn from_ne_bytes(bytes: [u8; 7]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u128, 72>
impl UInt<u128, 72>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 9]
pub const fn to_be_bytes(self) -> [u8; 9]
pub const fn from_le_bytes(from: [u8; 9]) -> Self
pub const fn from_be_bytes(from: [u8; 9]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 9]
pub const fn from_ne_bytes(bytes: [u8; 9]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u128, 80>
impl UInt<u128, 80>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 10]
pub const fn to_be_bytes(self) -> [u8; 10]
pub const fn from_le_bytes(from: [u8; 10]) -> Self
pub const fn from_be_bytes(from: [u8; 10]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 10]
pub const fn from_ne_bytes(bytes: [u8; 10]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u128, 88>
impl UInt<u128, 88>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 11]
pub const fn to_be_bytes(self) -> [u8; 11]
pub const fn from_le_bytes(from: [u8; 11]) -> Self
pub const fn from_be_bytes(from: [u8; 11]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 11]
pub const fn from_ne_bytes(bytes: [u8; 11]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u128, 96>
impl UInt<u128, 96>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 12]
pub const fn to_be_bytes(self) -> [u8; 12]
pub const fn from_le_bytes(from: [u8; 12]) -> Self
pub const fn from_be_bytes(from: [u8; 12]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 12]
pub const fn from_ne_bytes(bytes: [u8; 12]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u128, 104>
impl UInt<u128, 104>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 13]
pub const fn to_be_bytes(self) -> [u8; 13]
pub const fn from_le_bytes(from: [u8; 13]) -> Self
pub const fn from_be_bytes(from: [u8; 13]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 13]
pub const fn from_ne_bytes(bytes: [u8; 13]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u128, 112>
impl UInt<u128, 112>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 14]
pub const fn to_be_bytes(self) -> [u8; 14]
pub const fn from_le_bytes(from: [u8; 14]) -> Self
pub const fn from_be_bytes(from: [u8; 14]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 14]
pub const fn from_ne_bytes(bytes: [u8; 14]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Source§impl UInt<u128, 120>
impl UInt<u128, 120>
Sourcepub const fn swap_bytes(self) -> Self
pub const fn swap_bytes(self) -> Self
Reverses the byte order of the integer.
pub const fn to_le_bytes(self) -> [u8; 15]
pub const fn to_be_bytes(self) -> [u8; 15]
pub const fn from_le_bytes(from: [u8; 15]) -> Self
pub const fn from_be_bytes(from: [u8; 15]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 15]
pub const fn from_ne_bytes(bytes: [u8; 15]) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_le(value: Self) -> Self
pub const fn from_be(value: Self) -> Self
Trait Implementations§
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Add for UInt<T, BITS>where
Self: UnsignedInteger,
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Add for UInt<T, BITS>where
Self: UnsignedInteger,
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> AddAssign for UInt<T, BITS>where
Self: UnsignedInteger,
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> AddAssign for UInt<T, BITS>where
Self: UnsignedInteger,
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moreSource§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Binary for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Binary for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitAnd for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitAnd for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitAndAssign for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitAndAssign for UInt<T, BITS>
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moreSource§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitOr for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitOr for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitOrAssign for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitOrAssign for UInt<T, BITS>
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moreSource§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitXor for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitXor for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitXorAssign for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> BitXorAssign for UInt<T, BITS>
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^=
operation. Read moreSource§impl<T: Clone + UnsignedInteger + BuiltinInteger, const BITS: usize> Clone for UInt<T, BITS>
impl<T: Clone + UnsignedInteger + BuiltinInteger, const BITS: usize> Clone for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Debug for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Debug for UInt<T, BITS>
Source§impl<T: Default + UnsignedInteger + BuiltinInteger, const BITS: usize> Default for UInt<T, BITS>
impl<T: Default + UnsignedInteger + BuiltinInteger, const BITS: usize> Default for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Display for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Display for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Div for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Div for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> DivAssign for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> DivAssign for UInt<T, BITS>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/=
operation. Read moreSource§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u128, BITS_FROM>> for UInt<u16, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u128, BITS_FROM>> for UInt<u16, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u128, BITS_FROM>> for UInt<u32, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u128, BITS_FROM>> for UInt<u32, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u128, BITS_FROM>> for UInt<u64, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u128, BITS_FROM>> for UInt<u64, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u128, BITS_FROM>> for UInt<u8, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u128, BITS_FROM>> for UInt<u8, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u16, BITS_FROM>> for UInt<u128, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u16, BITS_FROM>> for UInt<u128, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u16, BITS_FROM>> for UInt<u32, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u16, BITS_FROM>> for UInt<u32, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u16, BITS_FROM>> for UInt<u64, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u16, BITS_FROM>> for UInt<u64, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u16, BITS_FROM>> for UInt<u8, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u16, BITS_FROM>> for UInt<u8, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u32, BITS_FROM>> for UInt<u128, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u32, BITS_FROM>> for UInt<u128, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u32, BITS_FROM>> for UInt<u16, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u32, BITS_FROM>> for UInt<u16, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u32, BITS_FROM>> for UInt<u64, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u32, BITS_FROM>> for UInt<u64, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u32, BITS_FROM>> for UInt<u8, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u32, BITS_FROM>> for UInt<u8, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u64, BITS_FROM>> for UInt<u128, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u64, BITS_FROM>> for UInt<u128, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u64, BITS_FROM>> for UInt<u16, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u64, BITS_FROM>> for UInt<u16, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u64, BITS_FROM>> for UInt<u32, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u64, BITS_FROM>> for UInt<u32, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u64, BITS_FROM>> for UInt<u8, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u64, BITS_FROM>> for UInt<u8, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u8, BITS_FROM>> for UInt<u128, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u8, BITS_FROM>> for UInt<u128, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u8, BITS_FROM>> for UInt<u16, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u8, BITS_FROM>> for UInt<u16, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u8, BITS_FROM>> for UInt<u32, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u8, BITS_FROM>> for UInt<u32, BITS>
Source§impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u8, BITS_FROM>> for UInt<u64, BITS>
impl<const BITS: usize, const BITS_FROM: usize> From<UInt<u8, BITS_FROM>> for UInt<u64, BITS>
Source§impl<T: Hash + UnsignedInteger + BuiltinInteger, const BITS: usize> Hash for UInt<T, BITS>
impl<T: Hash + UnsignedInteger + BuiltinInteger, const BITS: usize> Hash for UInt<T, BITS>
Source§impl<const BITS: usize> Integer for UInt<u128, BITS>
impl<const BITS: usize> Integer for UInt<u128, BITS>
type UnderlyingType = u128
Source§type SignedInteger = Int<i128, BITS>
type SignedInteger = Int<i128, BITS>
Source§type UnsignedInteger = UInt<u128, BITS>
type UnsignedInteger = UInt<u128, BITS>
Source§fn try_new(value: Self::UnderlyingType) -> Result<Self, TryNewError>
fn try_new(value: Self::UnderlyingType) -> Result<Self, TryNewError>
Source§fn new(value: u128) -> Self
fn new(value: u128) -> Self
Source§fn from_<T: Integer>(value: T) -> Self
fn from_<T: Integer>(value: T) -> Self
Self::new
for literals.Source§fn masked_new<T: Integer>(value: T) -> Self
fn masked_new<T: Integer>(value: T) -> Self
value
. Unlike the various new...
functions, this
will never fail as the value is masked to the result size.fn as_u8(self) -> u8
fn as_u16(self) -> u16
fn as_u32(self) -> u32
fn as_u64(self) -> u64
fn as_u128(self) -> u128
fn as_usize(self) -> usize
fn as_i8(self) -> i8
fn as_i16(self) -> i16
fn as_i32(self) -> i32
fn as_i64(self) -> i64
fn as_i128(self) -> i128
fn as_isize(self) -> isize
Source§fn to_unsigned(self) -> Self::UnsignedInteger
fn to_unsigned(self) -> Self::UnsignedInteger
Source§fn from_unsigned(value: Self::UnsignedInteger) -> Self
fn from_unsigned(value: Self::UnsignedInteger) -> Self
fn value(self) -> u128
fn as_<T: Integer>(self) -> T
Source§impl<const BITS: usize> Integer for UInt<u16, BITS>
impl<const BITS: usize> Integer for UInt<u16, BITS>
type UnderlyingType = u16
Source§type SignedInteger = Int<i16, BITS>
type SignedInteger = Int<i16, BITS>
Source§type UnsignedInteger = UInt<u16, BITS>
type UnsignedInteger = UInt<u16, BITS>
Source§fn try_new(value: Self::UnderlyingType) -> Result<Self, TryNewError>
fn try_new(value: Self::UnderlyingType) -> Result<Self, TryNewError>
Source§fn new(value: u16) -> Self
fn new(value: u16) -> Self
Source§fn from_<T: Integer>(value: T) -> Self
fn from_<T: Integer>(value: T) -> Self
Self::new
for literals.Source§fn masked_new<T: Integer>(value: T) -> Self
fn masked_new<T: Integer>(value: T) -> Self
value
. Unlike the various new...
functions, this
will never fail as the value is masked to the result size.fn as_u8(self) -> u8
fn as_u16(self) -> u16
fn as_u32(self) -> u32
fn as_u64(self) -> u64
fn as_u128(self) -> u128
fn as_usize(self) -> usize
fn as_i8(self) -> i8
fn as_i16(self) -> i16
fn as_i32(self) -> i32
fn as_i64(self) -> i64
fn as_i128(self) -> i128
fn as_isize(self) -> isize
Source§fn to_unsigned(self) -> Self::UnsignedInteger
fn to_unsigned(self) -> Self::UnsignedInteger
Source§fn from_unsigned(value: Self::UnsignedInteger) -> Self
fn from_unsigned(value: Self::UnsignedInteger) -> Self
fn value(self) -> u16
fn as_<T: Integer>(self) -> T
Source§impl<const BITS: usize> Integer for UInt<u32, BITS>
impl<const BITS: usize> Integer for UInt<u32, BITS>
type UnderlyingType = u32
Source§type SignedInteger = Int<i32, BITS>
type SignedInteger = Int<i32, BITS>
Source§type UnsignedInteger = UInt<u32, BITS>
type UnsignedInteger = UInt<u32, BITS>
Source§fn try_new(value: Self::UnderlyingType) -> Result<Self, TryNewError>
fn try_new(value: Self::UnderlyingType) -> Result<Self, TryNewError>
Source§fn new(value: u32) -> Self
fn new(value: u32) -> Self
Source§fn from_<T: Integer>(value: T) -> Self
fn from_<T: Integer>(value: T) -> Self
Self::new
for literals.Source§fn masked_new<T: Integer>(value: T) -> Self
fn masked_new<T: Integer>(value: T) -> Self
value
. Unlike the various new...
functions, this
will never fail as the value is masked to the result size.fn as_u8(self) -> u8
fn as_u16(self) -> u16
fn as_u32(self) -> u32
fn as_u64(self) -> u64
fn as_u128(self) -> u128
fn as_usize(self) -> usize
fn as_i8(self) -> i8
fn as_i16(self) -> i16
fn as_i32(self) -> i32
fn as_i64(self) -> i64
fn as_i128(self) -> i128
fn as_isize(self) -> isize
Source§fn to_unsigned(self) -> Self::UnsignedInteger
fn to_unsigned(self) -> Self::UnsignedInteger
Source§fn from_unsigned(value: Self::UnsignedInteger) -> Self
fn from_unsigned(value: Self::UnsignedInteger) -> Self
fn value(self) -> u32
fn as_<T: Integer>(self) -> T
Source§impl<const BITS: usize> Integer for UInt<u64, BITS>
impl<const BITS: usize> Integer for UInt<u64, BITS>
type UnderlyingType = u64
Source§type SignedInteger = Int<i64, BITS>
type SignedInteger = Int<i64, BITS>
Source§type UnsignedInteger = UInt<u64, BITS>
type UnsignedInteger = UInt<u64, BITS>
Source§fn try_new(value: Self::UnderlyingType) -> Result<Self, TryNewError>
fn try_new(value: Self::UnderlyingType) -> Result<Self, TryNewError>
Source§fn new(value: u64) -> Self
fn new(value: u64) -> Self
Source§fn from_<T: Integer>(value: T) -> Self
fn from_<T: Integer>(value: T) -> Self
Self::new
for literals.Source§fn masked_new<T: Integer>(value: T) -> Self
fn masked_new<T: Integer>(value: T) -> Self
value
. Unlike the various new...
functions, this
will never fail as the value is masked to the result size.fn as_u8(self) -> u8
fn as_u16(self) -> u16
fn as_u32(self) -> u32
fn as_u64(self) -> u64
fn as_u128(self) -> u128
fn as_usize(self) -> usize
fn as_i8(self) -> i8
fn as_i16(self) -> i16
fn as_i32(self) -> i32
fn as_i64(self) -> i64
fn as_i128(self) -> i128
fn as_isize(self) -> isize
Source§fn to_unsigned(self) -> Self::UnsignedInteger
fn to_unsigned(self) -> Self::UnsignedInteger
Source§fn from_unsigned(value: Self::UnsignedInteger) -> Self
fn from_unsigned(value: Self::UnsignedInteger) -> Self
fn value(self) -> u64
fn as_<T: Integer>(self) -> T
Source§impl<const BITS: usize> Integer for UInt<u8, BITS>
impl<const BITS: usize> Integer for UInt<u8, BITS>
type UnderlyingType = u8
Source§type SignedInteger = Int<i8, BITS>
type SignedInteger = Int<i8, BITS>
Source§type UnsignedInteger = UInt<u8, BITS>
type UnsignedInteger = UInt<u8, BITS>
Source§fn try_new(value: Self::UnderlyingType) -> Result<Self, TryNewError>
fn try_new(value: Self::UnderlyingType) -> Result<Self, TryNewError>
Source§fn new(value: u8) -> Self
fn new(value: u8) -> Self
Source§fn from_<T: Integer>(value: T) -> Self
fn from_<T: Integer>(value: T) -> Self
Self::new
for literals.Source§fn masked_new<T: Integer>(value: T) -> Self
fn masked_new<T: Integer>(value: T) -> Self
value
. Unlike the various new...
functions, this
will never fail as the value is masked to the result size.fn as_u8(self) -> u8
fn as_u16(self) -> u16
fn as_u32(self) -> u32
fn as_u64(self) -> u64
fn as_u128(self) -> u128
fn as_usize(self) -> usize
fn as_i8(self) -> i8
fn as_i16(self) -> i16
fn as_i32(self) -> i32
fn as_i64(self) -> i64
fn as_i128(self) -> i128
fn as_isize(self) -> isize
Source§fn to_unsigned(self) -> Self::UnsignedInteger
fn to_unsigned(self) -> Self::UnsignedInteger
Source§fn from_unsigned(value: Self::UnsignedInteger) -> Self
fn from_unsigned(value: Self::UnsignedInteger) -> Self
fn value(self) -> u8
fn as_<T: Integer>(self) -> T
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> LowerHex for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> LowerHex for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Mul for UInt<T, BITS>where
Self: Integer,
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Mul for UInt<T, BITS>where
Self: Integer,
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> MulAssign for UInt<T, BITS>where
Self: Integer,
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> MulAssign for UInt<T, BITS>where
Self: Integer,
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*=
operation. Read moreSource§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Not for UInt<T, BITS>where
Self: Integer,
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Not for UInt<T, BITS>where
Self: Integer,
Source§impl<const BITS: usize> Number for UInt<u128, BITS>
impl<const BITS: usize> Number for UInt<u128, BITS>
Source§type UnderlyingType = u128
type UnderlyingType = u128
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const BITS: usize = <Self as Integer>::BITS
const BITS: usize = <Self as Integer>::BITS
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const MIN: Self = <Self as Integer>::MIN
const MIN: Self = <Self as Integer>::MIN
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const MAX: Self = <Self as Integer>::MAX
const MAX: Self = <Self as Integer>::MAX
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn new(value: <Self as Number>::UnderlyingType) -> Self
fn new(value: <Self as Number>::UnderlyingType) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn try_new(value: <Self as Number>::UnderlyingType) -> Result<Self, TryNewError>
fn try_new(value: <Self as Number>::UnderlyingType) -> Result<Self, TryNewError>
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn value(self) -> <Self as Number>::UnderlyingType
fn value(self) -> <Self as Number>::UnderlyingType
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn from_<T: Number>(value: T) -> Self
fn from_<T: Number>(value: T) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Self::new
for literals.Source§fn masked_new<T: Number>(value: T) -> Self
fn masked_new<T: Number>(value: T) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.value
. Unlike the various new...
functions, this
will never fail as the value is masked to the result size.Source§fn as_u8(&self) -> u8
fn as_u8(&self) -> u8
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u16(&self) -> u16
fn as_u16(&self) -> u16
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u32(&self) -> u32
fn as_u32(&self) -> u32
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u64(&self) -> u64
fn as_u64(&self) -> u64
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u128(&self) -> u128
fn as_u128(&self) -> u128
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§impl<const BITS: usize> Number for UInt<u16, BITS>
impl<const BITS: usize> Number for UInt<u16, BITS>
Source§type UnderlyingType = u16
type UnderlyingType = u16
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const BITS: usize = <Self as Integer>::BITS
const BITS: usize = <Self as Integer>::BITS
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const MIN: Self = <Self as Integer>::MIN
const MIN: Self = <Self as Integer>::MIN
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const MAX: Self = <Self as Integer>::MAX
const MAX: Self = <Self as Integer>::MAX
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn new(value: <Self as Number>::UnderlyingType) -> Self
fn new(value: <Self as Number>::UnderlyingType) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn try_new(value: <Self as Number>::UnderlyingType) -> Result<Self, TryNewError>
fn try_new(value: <Self as Number>::UnderlyingType) -> Result<Self, TryNewError>
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn value(self) -> <Self as Number>::UnderlyingType
fn value(self) -> <Self as Number>::UnderlyingType
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn from_<T: Number>(value: T) -> Self
fn from_<T: Number>(value: T) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Self::new
for literals.Source§fn masked_new<T: Number>(value: T) -> Self
fn masked_new<T: Number>(value: T) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.value
. Unlike the various new...
functions, this
will never fail as the value is masked to the result size.Source§fn as_u8(&self) -> u8
fn as_u8(&self) -> u8
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u16(&self) -> u16
fn as_u16(&self) -> u16
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u32(&self) -> u32
fn as_u32(&self) -> u32
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u64(&self) -> u64
fn as_u64(&self) -> u64
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u128(&self) -> u128
fn as_u128(&self) -> u128
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§impl<const BITS: usize> Number for UInt<u32, BITS>
impl<const BITS: usize> Number for UInt<u32, BITS>
Source§type UnderlyingType = u32
type UnderlyingType = u32
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const BITS: usize = <Self as Integer>::BITS
const BITS: usize = <Self as Integer>::BITS
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const MIN: Self = <Self as Integer>::MIN
const MIN: Self = <Self as Integer>::MIN
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const MAX: Self = <Self as Integer>::MAX
const MAX: Self = <Self as Integer>::MAX
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn new(value: <Self as Number>::UnderlyingType) -> Self
fn new(value: <Self as Number>::UnderlyingType) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn try_new(value: <Self as Number>::UnderlyingType) -> Result<Self, TryNewError>
fn try_new(value: <Self as Number>::UnderlyingType) -> Result<Self, TryNewError>
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn value(self) -> <Self as Number>::UnderlyingType
fn value(self) -> <Self as Number>::UnderlyingType
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn from_<T: Number>(value: T) -> Self
fn from_<T: Number>(value: T) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Self::new
for literals.Source§fn masked_new<T: Number>(value: T) -> Self
fn masked_new<T: Number>(value: T) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.value
. Unlike the various new...
functions, this
will never fail as the value is masked to the result size.Source§fn as_u8(&self) -> u8
fn as_u8(&self) -> u8
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u16(&self) -> u16
fn as_u16(&self) -> u16
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u32(&self) -> u32
fn as_u32(&self) -> u32
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u64(&self) -> u64
fn as_u64(&self) -> u64
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u128(&self) -> u128
fn as_u128(&self) -> u128
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§impl<const BITS: usize> Number for UInt<u64, BITS>
impl<const BITS: usize> Number for UInt<u64, BITS>
Source§type UnderlyingType = u64
type UnderlyingType = u64
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const BITS: usize = <Self as Integer>::BITS
const BITS: usize = <Self as Integer>::BITS
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const MIN: Self = <Self as Integer>::MIN
const MIN: Self = <Self as Integer>::MIN
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const MAX: Self = <Self as Integer>::MAX
const MAX: Self = <Self as Integer>::MAX
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn new(value: <Self as Number>::UnderlyingType) -> Self
fn new(value: <Self as Number>::UnderlyingType) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn try_new(value: <Self as Number>::UnderlyingType) -> Result<Self, TryNewError>
fn try_new(value: <Self as Number>::UnderlyingType) -> Result<Self, TryNewError>
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn value(self) -> <Self as Number>::UnderlyingType
fn value(self) -> <Self as Number>::UnderlyingType
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn from_<T: Number>(value: T) -> Self
fn from_<T: Number>(value: T) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Self::new
for literals.Source§fn masked_new<T: Number>(value: T) -> Self
fn masked_new<T: Number>(value: T) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.value
. Unlike the various new...
functions, this
will never fail as the value is masked to the result size.Source§fn as_u8(&self) -> u8
fn as_u8(&self) -> u8
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u16(&self) -> u16
fn as_u16(&self) -> u16
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u32(&self) -> u32
fn as_u32(&self) -> u32
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u64(&self) -> u64
fn as_u64(&self) -> u64
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u128(&self) -> u128
fn as_u128(&self) -> u128
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§impl<const BITS: usize> Number for UInt<u8, BITS>
impl<const BITS: usize> Number for UInt<u8, BITS>
Source§type UnderlyingType = u8
type UnderlyingType = u8
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const BITS: usize = <Self as Integer>::BITS
const BITS: usize = <Self as Integer>::BITS
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const MIN: Self = <Self as Integer>::MIN
const MIN: Self = <Self as Integer>::MIN
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§const MAX: Self = <Self as Integer>::MAX
const MAX: Self = <Self as Integer>::MAX
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn new(value: <Self as Number>::UnderlyingType) -> Self
fn new(value: <Self as Number>::UnderlyingType) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn try_new(value: <Self as Number>::UnderlyingType) -> Result<Self, TryNewError>
fn try_new(value: <Self as Number>::UnderlyingType) -> Result<Self, TryNewError>
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn value(self) -> <Self as Number>::UnderlyingType
fn value(self) -> <Self as Number>::UnderlyingType
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn from_<T: Number>(value: T) -> Self
fn from_<T: Number>(value: T) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Self::new
for literals.Source§fn masked_new<T: Number>(value: T) -> Self
fn masked_new<T: Number>(value: T) -> Self
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.value
. Unlike the various new...
functions, this
will never fail as the value is masked to the result size.Source§fn as_u8(&self) -> u8
fn as_u8(&self) -> u8
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u16(&self) -> u16
fn as_u16(&self) -> u16
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u32(&self) -> u32
fn as_u32(&self) -> u32
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u64(&self) -> u64
fn as_u64(&self) -> u64
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§fn as_u128(&self) -> u128
fn as_u128(&self) -> u128
UnsignedInteger
] or [Integer
] instead. Suggested to import via use arbitrary_int::prelude::*
.Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Octal for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Octal for UInt<T, BITS>
Source§impl<T: Ord + UnsignedInteger + BuiltinInteger, const BITS: usize> Ord for UInt<T, BITS>
impl<T: Ord + UnsignedInteger + BuiltinInteger, const BITS: usize> Ord for UInt<T, BITS>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialEq + UnsignedInteger + BuiltinInteger, const BITS: usize> PartialEq for UInt<T, BITS>
impl<T: PartialEq + UnsignedInteger + BuiltinInteger, const BITS: usize> PartialEq for UInt<T, BITS>
Source§impl<T: PartialOrd + UnsignedInteger + BuiltinInteger, const BITS: usize> PartialOrd for UInt<T, BITS>
impl<T: PartialOrd + UnsignedInteger + BuiltinInteger, const BITS: usize> PartialOrd for UInt<T, BITS>
Source§impl<'a, T: BuiltinInteger + UnsignedInteger, const BITS: usize> Product<&'a UInt<T, BITS>> for UInt<T, BITS>
impl<'a, T: BuiltinInteger + UnsignedInteger, const BITS: usize> Product<&'a UInt<T, BITS>> for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Product for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Product for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger + Shl<TSHIFTBITS, Output = T>, TSHIFTBITS: TryInto<usize> + Copy, const BITS: usize> Shl<TSHIFTBITS> for UInt<T, BITS>where
Self: Integer,
impl<T: BuiltinInteger + UnsignedInteger + Shl<TSHIFTBITS, Output = T>, TSHIFTBITS: TryInto<usize> + Copy, const BITS: usize> Shl<TSHIFTBITS> for UInt<T, BITS>where
Self: Integer,
Source§impl<T: BuiltinInteger + UnsignedInteger + ShlAssign<TSHIFTBITS>, TSHIFTBITS: TryInto<usize> + Copy, const BITS: usize> ShlAssign<TSHIFTBITS> for UInt<T, BITS>where
Self: Integer,
impl<T: BuiltinInteger + UnsignedInteger + ShlAssign<TSHIFTBITS>, TSHIFTBITS: TryInto<usize> + Copy, const BITS: usize> ShlAssign<TSHIFTBITS> for UInt<T, BITS>where
Self: Integer,
Source§fn shl_assign(&mut self, rhs: TSHIFTBITS)
fn shl_assign(&mut self, rhs: TSHIFTBITS)
<<=
operation. Read moreSource§impl<T: BuiltinInteger + UnsignedInteger + Shr<TSHIFTBITS, Output = T>, TSHIFTBITS: TryInto<usize> + Copy, const BITS: usize> Shr<TSHIFTBITS> for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger + Shr<TSHIFTBITS, Output = T>, TSHIFTBITS: TryInto<usize> + Copy, const BITS: usize> Shr<TSHIFTBITS> for UInt<T, BITS>
Source§impl<T: BuiltinInteger + UnsignedInteger + ShrAssign<TSHIFTBITS>, TSHIFTBITS: TryInto<usize> + Copy, const BITS: usize> ShrAssign<TSHIFTBITS> for UInt<T, BITS>
impl<T: BuiltinInteger + UnsignedInteger + ShrAssign<TSHIFTBITS>, TSHIFTBITS: TryInto<usize> + Copy, const BITS: usize> ShrAssign<TSHIFTBITS> for UInt<T, BITS>
Source§fn shr_assign(&mut self, rhs: TSHIFTBITS)
fn shr_assign(&mut self, rhs: TSHIFTBITS)
>>=
operation. Read moreSource§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Sub for UInt<T, BITS>where
Self: Integer,
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> Sub for UInt<T, BITS>where
Self: Integer,
Source§impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> SubAssign for UInt<T, BITS>where
Self: Integer,
impl<T: BuiltinInteger + UnsignedInteger, const BITS: usize> SubAssign for UInt<T, BITS>where
Self: Integer,
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read more