Expand description
The ring of numbers modulo $2^{\mathtt{BITS}}$.
Uint
implements nearly all traits and methods from the std
unsigned
integer types, including most nightly only ones.
Notable differences from std
uint types.
- The operators
+
,-
,*
, etc. using wrapping math by default. The std operators panic on overflow in debug, and are undefined in release, see reference. - The
Uint::checked_shl
,Uint::overflowing_shl
, etc return overflow when non-zero bits are shifted out. In std they return overflow when the shift amount is greater than the bit size. - Some methods like
u64::div_euclid
andu64::rem_euclid
are left out because they are meaningless or redundant for unsigned integers. Std has them for compatibility with their signed integers. - Many functions that are
const
in std are not inUint
. Uint::to_le_bytes
andUint::to_be_bytes
require the output size to be provided as a const-generic argument. They will runtime panic if the provided size is incorrect.Uint::widening_mul
takes as argument anUint
of arbitrary size and returns a result that is sized to fit the product without overflow (i.e. the sum of the bit sizes of self and the argument). The std version requires same-sized arguments and returns a pair of lower and higher bits.
Implementations
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub fn abs_diff(self, other: Self) -> Self
pub fn abs_diff(self, other: Self) -> Self
Computes the absolute difference between self
and other
.
Returns $\left\vert \mathtt{self} - \mathtt{other} \right\vert$.
sourcepub fn checked_add(self, rhs: Self) -> Option<Self>
pub fn checked_add(self, rhs: Self) -> Option<Self>
Computes self + rhs
, returning None
if overflow occurred.
sourcepub fn checked_neg(self) -> Option<Self>
pub fn checked_neg(self) -> Option<Self>
Computes -self
, returning None
unless self == 0
.
sourcepub fn checked_sub(self, rhs: Self) -> Option<Self>
pub fn checked_sub(self, rhs: Self) -> Option<Self>
Computes self - rhs
, returning None
if overflow occurred.
sourcepub fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub fn overflowing_add(self, rhs: Self) -> (Self, bool)
Calculates $\mod{\mathtt{self} + \mathtt{rhs}}_{2^{BITS}}$.
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.
sourcepub fn overflowing_neg(self) -> (Self, bool)
pub fn overflowing_neg(self) -> (Self, bool)
Calculates $\mod{-\mathtt{self}}_{2^{BITS}}$.
Returns !self + 1
using wrapping operations to return the value that
represents the negation of this unsigned value. Note that for positive
unsigned values overflow always occurs, but negating 0 does not
overflow.
sourcepub fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Calculates $\mod{\mathtt{self} - \mathtt{rhs}}_{2^{BITS}}$.
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.
sourcepub fn saturating_add(self, rhs: Self) -> Self
pub fn saturating_add(self, rhs: Self) -> Self
Computes self + rhs
, saturating at the numeric bounds instead of
overflowing.
sourcepub fn saturating_sub(self, rhs: Self) -> Self
pub fn saturating_sub(self, rhs: Self) -> Self
Computes self - rhs
, saturating at the numeric bounds instead of
overflowing
sourcepub fn wrapping_add(self, rhs: Self) -> Self
pub fn wrapping_add(self, rhs: Self) -> Self
Computes self + rhs
, wrapping around at the boundary of the type.
sourcepub fn wrapping_neg(self) -> Self
pub fn wrapping_neg(self) -> Self
Computes -self
, wrapping around at the boundary of the type.
sourcepub fn wrapping_sub(self, rhs: Self) -> Self
pub fn wrapping_sub(self, rhs: Self) -> Self
Computes self - rhs
, wrapping around at the boundary of the type.
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub fn to_base_le(&self, base: u64) -> impl Iterator<Item = u64>
pub fn to_base_le(&self, base: u64) -> impl Iterator<Item = u64>
Returns an iterator over the base base
digits of the number in
little-endian order.
Pro tip: instead of setting base = 10
, set it to the highest
power of 10
that still fits u64
. This way much fewer iterations
are required to extract all the digits.
Panics
Panics if the base is less than 2.
sourcepub fn to_base_be(&self, base: u64) -> impl Iterator<Item = u64>
pub fn to_base_be(&self, base: u64) -> impl Iterator<Item = u64>
Returns an iterator over the base base
digits of the number in
big-endian order.
Pro tip: instead of setting base = 10
, set it to the highest
power of 10
that still fits u64
. This way much fewer iterations
are required to extract all the digits.
Panics
Panics if the base is less than 2.
sourcepub fn from_base_le<I: IntoIterator<Item = u64>>(
base: u64,
digits: I
) -> Result<Self, BaseConvertError>
pub fn from_base_le<I: IntoIterator<Item = u64>>(
base: u64,
digits: I
) -> Result<Self, BaseConvertError>
Constructs the Uint
from digits in the base base
in little-endian.
Errors
BaseConvertError::InvalidBase
if the base is less than 2.BaseConvertError::InvalidDigit
if a digit is out of range.BaseConvertError::Overflow
if the number is too large to fit.
sourcepub fn from_base_be<I: IntoIterator<Item = u64>>(
base: u64,
digits: I
) -> Result<Self, BaseConvertError>
pub fn from_base_be<I: IntoIterator<Item = u64>>(
base: u64,
digits: I
) -> Result<Self, BaseConvertError>
Constructs the Uint
from digits in the base base
in big-endian.
Errors
BaseConvertError::InvalidBase
if the base is less than 2.BaseConvertError::InvalidDigit
if a digit is out of range.BaseConvertError::Overflow
if the number is too large to fit.
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
pub const fn bit(&self, index: usize) -> bool
pub fn set_bit(&mut self, index: usize, value: bool)
sourcepub fn reverse_bits(self) -> Self
pub 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.
sourcepub fn leading_zeros(&self) -> usize
pub fn leading_zeros(&self) -> usize
Returns the number of leading zeros in the binary representation of
self
.
sourcepub fn leading_ones(&self) -> usize
pub fn leading_ones(&self) -> usize
Returns the number of leading zeros in the binary representation of
self
.
sourcepub fn trailing_zeros(&self) -> usize
pub fn trailing_zeros(&self) -> usize
Returns the number of trailing zeros in the binary representation of
self
.
sourcepub fn trailing_ones(&self) -> usize
pub fn trailing_ones(&self) -> usize
Returns the number of trailing ones in the binary representation of
self
.
sourcepub fn count_ones(&self) -> usize
pub fn count_ones(&self) -> usize
Returns the number of ones in the binary representation of self
.
sourcepub fn count_zeros(&self) -> usize
pub fn count_zeros(&self) -> usize
Returns the number of zeros in the binary representation of self
.
sourcepub fn most_significant_bits(&self) -> (u64, usize)
pub fn most_significant_bits(&self) -> (u64, usize)
Returns the most significant 64 bits of the number and the exponent.
Given return value $(\mathtt{bits}, \mathtt{exponent})$, the self
can
be approximated as
$$ \mathtt{self} ≈ \mathtt{bits} ⋅ 2^\mathtt{exponent} $$
If self
is $<≥> 2^{63}$, then exponent
will be zero and bits
will
have leading zeros.
sourcepub fn checked_shl(self, rhs: usize) -> Option<Self>
pub fn checked_shl(self, rhs: usize) -> Option<Self>
Checked left shift by rhs
bits.
Returns $\mathtt{self} ⋅ 2^{\mathtt{rhs}}$ or None
if the result
would $≥ 2^{\mathtt{BITS}}$. That is, it returns None
if the bits
shifted out would be non-zero.
Note: This differs from u64::checked_shl
which returns None
if the
shift is larger than BITS (which is IMHO not very useful).
sourcepub fn saturating_shl(self, rhs: usize) -> Self
pub fn saturating_shl(self, rhs: usize) -> Self
sourcepub fn overflowing_shl(self, rhs: usize) -> (Self, bool)
pub fn overflowing_shl(self, rhs: usize) -> (Self, bool)
Left shift by rhs
bits with overflow detection.
Returns $\mod{\mathtt{value} ⋅ 2^{\mathtt{rhs}}}_{2^{\mathtt{BITS}}}$.
If the product is $≥ 2^{\mathtt{BITS}}$ it returns true
. That is, it
returns true if the bits shifted out are non-zero.
Note: This differs from u64::overflowing_shl
which returns true
if
the shift is larger than BITS
(which is IMHO not very useful).
sourcepub fn wrapping_shl(self, rhs: usize) -> Self
pub fn wrapping_shl(self, rhs: usize) -> Self
Left shift by rhs
bits.
Returns $\mod{\mathtt{value} ⋅ 2^{\mathtt{rhs}}}_{2^{\mathtt{BITS}}}$.
Note: This differs from u64::wrapping_shl
which first reduces rhs
by BITS
(which is IMHO not very useful).
sourcepub fn checked_shr(self, rhs: usize) -> Option<Self>
pub fn checked_shr(self, rhs: usize) -> Option<Self>
Checked right shift by rhs
bits.
$$ \frac{\mathtt{self}}{2^{\mathtt{rhs}}} $$
Returns the above or None
if the division is not exact. This is the
same as
Note: This differs from u64::checked_shr
which returns None
if the
shift is larger than BITS (which is IMHO not very useful).
sourcepub fn overflowing_shr(self, rhs: usize) -> (Self, bool)
pub fn overflowing_shr(self, rhs: usize) -> (Self, bool)
Right shift by rhs
bits with underflow detection.
$$ \floor{\frac{\mathtt{self}}{2^{\mathtt{rhs}}}} $$
Returns the above and false
if the division was exact, and true
if
it was rounded down. This is the same as non-zero bits being shifted
out.
Note: This differs from u64::overflowing_shl
which returns true
if
the shift is larger than BITS
(which is IMHO not very useful).
sourcepub fn wrapping_shr(self, rhs: usize) -> Self
pub fn wrapping_shr(self, rhs: usize) -> Self
Right shift by rhs
bits.
$$ \mathtt{wrapping\_shr}(\mathtt{self}, \mathtt{rhs}) = \floor{\frac{\mathtt{self}}{2^{\mathtt{rhs}}}} $$
Note: This differs from u64::wrapping_shr
which first reduces rhs
by BITS
(which is IMHO not very useful).
sourcepub fn rotate_left(self, rhs: usize) -> Self
pub fn rotate_left(self, rhs: usize) -> Self
Shifts the bits to the left by a specified amount, rhs
, wrapping the
truncated bits to the end of the resulting integer.
pub fn rotate_right(self, rhs: usize) -> Self
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub const BYTES: usize = (BITS + 7) / 8
pub const BYTES: usize = (BITS + 7) / 8
The size of this integer type in bytes. Note that some bits may be forced zero if BITS is not cleanly divisible by eight.
sourcepub fn as_le_slice(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn as_le_slice(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
Access the underlying store as a little-endian slice of bytes.
Only available on litte-endian targets.
If BITS
does not evenly divide 8, it is padded with zero bits in the
most significant position.
sourcepub unsafe fn as_le_slice_mut(&mut self) -> &mut [u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub unsafe fn as_le_slice_mut(&mut self) -> &mut [u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
sourcepub fn as_le_bytes(&self) -> Cow<'_, [u8]>
pub fn as_le_bytes(&self) -> Cow<'_, [u8]>
Access the underlying store as a little-endian bytes.
Uses an optimized implementation on little-endian targets.
sourcepub fn as_le_bytes_trimmed(&self) -> Cow<'_, [u8]>
pub fn as_le_bytes_trimmed(&self) -> Cow<'_, [u8]>
Access the underlying store as a little-endian bytes with trailing zeros removed.
Uses an optimized implementation on little-endian targets.
sourcepub fn to_le_bytes<const BYTES: usize>(&self) -> [u8; BYTES]
pub fn to_le_bytes<const BYTES: usize>(&self) -> [u8; BYTES]
Converts the Uint
to a little-endian byte array of size exactly
Self::BYTES
.
Panics
Panics if the generic parameter BYTES
is not exactly Self::BYTES
.
Ideally this would be a compile time error, but this is blocked by
Rust issue #60551.
sourcepub fn to_le_bytes_vec(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn to_le_bytes_vec(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Converts the Uint
to a little-endian byte vector of size exactly
Self::BYTES
.
This method is useful when Self::to_le_bytes
can not be used because
byte size is not known compile time.
sourcepub fn to_le_bytes_trimmed_vec(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn to_le_bytes_trimmed_vec(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Converts the Uint
to a little-endian byte vector with trailing zeros
bytes removed.
sourcepub fn to_be_bytes<const BYTES: usize>(&self) -> [u8; BYTES]
pub fn to_be_bytes<const BYTES: usize>(&self) -> [u8; BYTES]
Converts the Uint
to a big-endian byte array of size exactly
Self::BYTES
.
Panics
Panics if the generic parameter BYTES
is not exactly Self::BYTES
.
Ideally this would be a compile time error, but this is blocked by
Rust issue #60551.
sourcepub fn to_be_bytes_vec(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn to_be_bytes_vec(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Converts the Uint
to a big-endian byte vector of size exactly
Self::BYTES
.
This method is useful when Self::to_be_bytes
can not be used because
byte size is not known compile time.
sourcepub fn to_be_bytes_trimmed_vec(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn to_be_bytes_trimmed_vec(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Converts the Uint
to a big-endian byte vector with leading zeros
bytes removed.
sourcepub fn from_be_bytes<const BYTES: usize>(bytes: [u8; BYTES]) -> Self
pub fn from_be_bytes<const BYTES: usize>(bytes: [u8; BYTES]) -> Self
Converts a big-endian byte array of size exactly
Self::BYTES
to Uint
.
Panics
Panics if the generic parameter BYTES
is not exactly Self::BYTES
.
Ideally this would be a compile time error, but this is blocked by
Rust issue #60551.
Panics if the value is too large for the bit-size of the Uint.
sourcepub fn from_le_bytes<const BYTES: usize>(bytes: [u8; BYTES]) -> Self
pub fn from_le_bytes<const BYTES: usize>(bytes: [u8; BYTES]) -> Self
Converts a little-endian byte array of size exactly
Self::BYTES
to Uint
.
Panics
Panics if the generic parameter BYTES
is not exactly Self::BYTES
.
Ideally this would be a compile time error, but this is blocked by
Rust issue #60551.
Panics if the value is too large for the bit-size of the Uint.
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub fn checked_div(self, rhs: Self) -> Option<Self>
pub fn checked_div(self, rhs: Self) -> Option<Self>
Computes self / rhs
, returning None
if rhs == 0
.
sourcepub fn checked_rem(self, rhs: Self) -> Option<Self>
pub fn checked_rem(self, rhs: Self) -> Option<Self>
Computes self % rhs
, returning None
if rhs == 0
.
sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
sourcepub fn wrapping_rem(self, rhs: Self) -> Self
pub fn wrapping_rem(self, rhs: Self) -> Self
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub fn gcd_extended(self, other: Self) -> (Self, Self, Self, bool)
pub fn gcd_extended(self, other: Self) -> (Self, Self, Self, bool)
⚠️ Compute the greatest common divisor and the Bézout coefficients.
Warning. This is API is unstable and may change in a minor release.
Returns $(\mathtt{gcd}, \mathtt{x}, \mathtt{y}, \mathtt{sign})$ such that
$$ \gcd(\mathtt{self}, \mathtt{other}) = \mathtt{gcd} = \begin{cases} \mathtt{self} · \mathtt{x} - \mathtt{other} . \mathtt{y} & \mathtt{sign} \\ \mathtt{other} · \mathtt{y} - \mathtt{self} · \mathtt{x} & ¬\mathtt{sign} \end{cases} $$
Note that the intermediate products may overflow, even though the result
after subtraction will fit in the bit size of the Uint
.
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
pub fn checked_log(self, base: u64) -> Option<usize>
pub fn checked_log10(self) -> Option<usize>
sourcepub fn checked_log2(self) -> Option<usize>
pub fn checked_log2(self) -> Option<usize>
Returns the base 2 logarithm of the number, rounded down.
This is equivalent to the index of the highest set bit.
Returns None if the number is zero.
sourcepub fn log(self, base: u64) -> usize
pub fn log(self, base: u64) -> usize
Panics
Panics if the base
is less than 2 or if the number is zero.
pub fn log10(self) -> usize
pub fn log2(self) -> usize
sourcepub fn approx_log(self, base: f64) -> f64
pub fn approx_log(self, base: f64) -> f64
Double precision logarithm.
sourcepub fn approx_log2(self) -> f64
pub fn approx_log2(self) -> f64
Double precision binary logarithm.
Examples
assert_eq!(0_U64.approx_log2(), f64::NEG_INFINITY);
assert_eq!(1_U64.approx_log2(), 0.0);
assert_eq!(2_U64.approx_log2(), 1.0);
assert_eq!(U64::MAX.approx_log2(), 64.0);
sourcepub fn approx_log10(self) -> f64
pub fn approx_log10(self) -> f64
Double precision decimal logarithm.
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub fn reduce_mod(self, modulus: Self) -> Self
pub fn reduce_mod(self, modulus: Self) -> Self
⚠️ Compute $\mod{\mathtt{self}}_{\mathtt{modulus}}$.
Warning. This function is not part of the stable API.
Returns zero if the modulus is zero.
sourcepub fn add_mod(self, rhs: Self, modulus: Self) -> Self
pub fn add_mod(self, rhs: Self, modulus: Self) -> Self
Compute $\mod{\mathtt{self} + \mathtt{rhs}}_{\mathtt{modulus}}$.
Returns zero if the modulus is zero.
sourcepub fn mul_mod(self, rhs: Self, modulus: Self) -> Self
pub fn mul_mod(self, rhs: Self, modulus: Self) -> Self
Compute $\mod{\mathtt{self} ⋅ \mathtt{rhs}}_{\mathtt{modulus}}$.
Returns zero if the modulus is zero.
See mul_redc
for a faster variant at the cost of
some pre-computation.
sourcepub fn pow_mod(self, exp: Self, modulus: Self) -> Self
pub fn pow_mod(self, exp: Self, modulus: Self) -> Self
Compute $\mod{\mathtt{self}^{\mathtt{rhs}}}_{\mathtt{modulus}}$.
Returns zero if the modulus is zero.
sourcepub fn inv_mod(self, modulus: Self) -> Option<Self>
pub fn inv_mod(self, modulus: Self) -> Option<Self>
Compute $\mod{\mathtt{self}^{-1}}_{\mathtt{modulus}}$.
Returns None
if the inverse does not exist.
sourcepub fn mul_redc(self, other: Self, modulus: Self, inv: u64) -> Self
pub fn mul_redc(self, other: Self, modulus: Self, inv: u64) -> Self
Montgomery multiplication.
Computes
$$ \mod{\frac{\mathtt{self} ⋅ \mathtt{other}}{ 2^{64 · \mathtt{LIMBS}}}}_{\mathtt{modulus}} $$
This is useful because it can be computed notably faster than
mul_mod
. Many computations can be done by
pre-multiplying values with $R = 2^{64 · \mathtt{LIMBS}}$
and then using mul_redc
instead of
mul_mod
.
For this algorithm to work, it needs an extra parameter inv
which must
be set to
$$ \mathtt{inv} = \mod{\frac{-1}{\mathtt{modulus}} }_{2^{64}} $$
The inv
value only exists for odd values of modulus
. It can be
computed using inv_ring
from U64
.
let inv = (-U64::from(modulus.as_limbs()[0]).inv_ring().unwrap()).as_limbs()[0];
Panics
Panics if inv
is not correct.
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub fn checked_mul(self, rhs: Self) -> Option<Self>
pub fn checked_mul(self, rhs: Self) -> Option<Self>
Computes self * rhs
, returning None
if overflow occurred.
sourcepub fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub 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
assert_eq!(1_U1.overflowing_mul(1_U1), (1_U1, false));
assert_eq!(0x010000000000000000_U65.overflowing_mul(0x010000000000000000_U65), (0x000000000000000000_U65, true));
sourcepub fn saturating_mul(self, rhs: Self) -> Self
pub fn saturating_mul(self, rhs: Self) -> Self
Computes self * rhs
, saturating at the numeric bounds instead of
overflowing.
sourcepub fn wrapping_mul(self, rhs: Self) -> Self
pub fn wrapping_mul(self, rhs: Self) -> Self
Computes self * rhs
, saturating at the numeric bounds instead of
overflowing.
sourcepub fn inv_ring(self) -> Option<Self>
pub fn inv_ring(self) -> Option<Self>
Computes the inverse modulo $2^{\mathtt{BITS}}$ of self
, returning
None
if the inverse does not exist.
sourcepub fn widening_mul<const BITS_RHS: usize, const LIMBS_RHS: usize, const BITS_RES: usize, const LIMBS_RES: usize>(
self,
rhs: Uint<BITS_RHS, LIMBS_RHS>
) -> Uint<BITS_RES, LIMBS_RES>
pub fn widening_mul<const BITS_RHS: usize, const LIMBS_RHS: usize, const BITS_RES: usize, const LIMBS_RES: usize>(
self,
rhs: Uint<BITS_RHS, LIMBS_RHS>
) -> Uint<BITS_RES, LIMBS_RES>
Calculates the complete product self * rhs
without the possibility to
overflow.
The argument rhs
can be any size Uint
, the result size is the sum
of the bit-sizes of self
and rhs
.
Panics
This function will runtime panic of the const generic arguments are incorrect.
Examples
assert_eq!(0_U0.widening_mul(0_U0), 0_U0);
assert_eq!(1_U1.widening_mul(1_U1), 1_U2);
assert_eq!(3_U2.widening_mul(7_U3), 21_U5);
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
pub fn checked_pow(self, exp: usize) -> Option<Self>
sourcepub fn overflowing_pow(self, exp: usize) -> (Self, bool)
pub fn overflowing_pow(self, exp: usize) -> (Self, bool)
Examples
assert_eq!(36_U64.overflowing_pow(12), (0x41c21cb8e1000000_U64, false));
assert_eq!(36_U64.overflowing_pow(13), (0x3f4c09ffa4000000_U64, true));
assert_eq!(36_U68.overflowing_pow(13), (0x093f4c09ffa4000000_U68, false));
assert_eq!(16_U65.overflowing_pow(32), (0_U65, true));
Small cases:
assert_eq!(0_U0.overflowing_pow(0), (0_U0, false));
assert_eq!(0_U1.overflowing_pow(0), (1_U1, false));
assert_eq!(0_U1.overflowing_pow(1), (0_U1, false));
assert_eq!(1_U1.overflowing_pow(0), (1_U1, false));
assert_eq!(1_U1.overflowing_pow(1), (1_U1, false));
pub fn pow(self, exp: usize) -> Self
pub fn saturating_pow(self, exp: usize) -> Self
pub fn wrapping_pow(self, exp: usize) -> Self
sourcepub fn approx_pow2(exp: f64) -> Option<Self>
pub fn approx_pow2(exp: f64) -> Option<Self>
Construct from double precision binary logarithm.
Examples
assert_eq!(U64::approx_pow2(-2.0), Some(0_U64));
assert_eq!(U64::approx_pow2(-1.0), Some(1_U64));
assert_eq!(U64::approx_pow2(0.0), Some(1_U64));
assert_eq!(U64::approx_pow2(1.0), Some(2_U64));
assert_eq!(U64::approx_pow2(1.6), Some(3_U64));
assert_eq!(U64::approx_pow2(2.0), Some(4_U64));
assert_eq!(U64::approx_pow2(64.0), None);
assert_eq!(U64::approx_pow2(10.385), Some(1337_U64));
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub fn root(self, degree: usize) -> Self
pub fn root(self, degree: usize) -> Self
Computes the floor of the degree
-th root of the number.
$$ \floor{\sqrt[\mathtt{degree}]{\mathtt{self}}} $$
Panics
Panics if degree
is zero.
Examples
assert_eq!(0_U64.root(2), 0_U64);
assert_eq!(1_U64.root(63), 1_U64);
assert_eq!(0x0032da8b0f88575d_U63.root(64), 1_U63);
assert_eq!(0x1756800000000000_U63.root(34), 3_U63);
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub fn is_power_of_two(self) -> bool
pub fn is_power_of_two(self) -> bool
Returns true
if and only if self == 2^k
for some k
.
sourcepub fn next_power_of_two(self) -> Self
pub fn next_power_of_two(self) -> Self
Returns the smallest power of two greater than or equal to self.
Panics
Panics if the value overlfows.
sourcepub fn checked_next_power_of_two(self) -> Option<Self>
pub fn checked_next_power_of_two(self) -> Option<Self>
Returns the smallest power of two greater than or equal to self
. If
the next power of two is greater than the type’s maximum value,
None
is returned, otherwise the power of two is wrapped in
Some
.
Examples
assert_eq!(0_U64.checked_next_power_of_two(), Some(1_U64));
assert_eq!(1_U64.checked_next_power_of_two(), Some(1_U64));
assert_eq!(2_U64.checked_next_power_of_two(), Some(2_U64));
assert_eq!(3_U64.checked_next_power_of_two(), Some(4_U64));
assert_eq!(U64::MAX.checked_next_power_of_two(), None);
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub fn next_multiple_of(self, rhs: Self) -> Self
pub fn next_multiple_of(self, rhs: Self) -> Self
Calculates the smallest value greater than or equal to self that is a multiple of rhs.
Panics
This function will panic if rhs
is 0 or the operation results in
overflow.
sourcepub fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>
pub fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>
Calculates the smallest value greater than or equal to self
that is a
multiple of rhs
. Returns None
is rhs
is zero or the
operation would result in overflow.
Examples
assert_eq!(16_U64.checked_next_multiple_of(8_U64), Some(16_U64));
assert_eq!(23_U64.checked_next_multiple_of(8_U64), Some(24_U64));
assert_eq!(1_U64.checked_next_multiple_of(0_U64), None);
assert_eq!(U64::MAX.checked_next_multiple_of(2_U64), None);
}
assert_eq!(0_U0.checked_next_multiple_of(0_U0), None);
assert_eq!(0_U1.checked_next_multiple_of(0_U1), None);
assert_eq!(0_U1.checked_next_multiple_of(1_U1), Some(0_U1));
assert_eq!(1_U1.checked_next_multiple_of(0_U1), None);
assert_eq!(1_U1.checked_next_multiple_of(1_U1), Some(1_U1));
}
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub fn from_str_radix(src: &str, radix: u64) -> Result<Self, ParseError>
pub fn from_str_radix(src: &str, radix: u64) -> Result<Self, ParseError>
Parse a string into a Uint
.
For bases 2 to 36, the case-agnostic alphabet 0—1, a—b is used and _
are ignored. For bases 37 to 64, the case-sensitive alphabet a—z, A—Z,
0—9, {+-}, {/,_} is used. That is, for base 64 it is compatible with
all the common base64 variants.
Errors
ParseError::InvalidDigit
if the string contains a non-digit.ParseError::InvalidRadix
if the radix is larger than 64.ParseError::BaseConvertError
ifUint::from_base_be
fails.
sourceimpl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>
sourcepub const MIN: Self = Self::ZERO
pub const MIN: Self = Self::ZERO
The smallest value that can be represented by this integer type.
Synonym for Self::ZERO
.
sourcepub const ZERO: Self = Self { limbs: [0; LIMBS] }
pub const ZERO: Self = Self { limbs: [0; LIMBS] }
The value zero. This is the only value that exists in all Uint
types.
sourcepub const MAX: Self = {
let mut limbs = [u64::MAX; LIMBS];
if BITS > 0 {
limbs[LIMBS - 1] &= Self::MASK;
}
Self { limbs }
}
pub const MAX: Self = { let mut limbs = [u64::MAX; LIMBS]; if BITS > 0 { limbs[LIMBS - 1] &= Self::MASK; } Self { limbs } }
The largest value that can be represented by this integer type, $2^{\mathtt{BITS}} − 1$.
sourcepub unsafe fn as_limbs_mut(&mut self) -> &mut [u64; LIMBS]
pub unsafe fn as_limbs_mut(&mut self) -> &mut [u64; LIMBS]
Access the array of limbs.
Safety
This function is unsafe because it allows setting a bit outside the bit size if the bit-size is not limb-aligned.
sourcepub const fn into_limbs(self) -> [u64; LIMBS]
pub const fn into_limbs(self) -> [u64; LIMBS]
Convert to a array of limbs.
Limbs are least significant first.
sourcepub const fn from_limbs(limbs: [u64; LIMBS]) -> Self
pub const fn from_limbs(limbs: [u64; LIMBS]) -> Self
Construct a new integer from little-endian a array of limbs.
Panics
Panics it LIMBS
is not equal to nlimbs(BITS)
.
Panics if the value is to large for the bit-size of the Uint.
Trait Implementations
sourceimpl<const BITS: usize, const LIMBS: usize> AddAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> AddAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn add_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
fn add_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
Performs the +=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> AddAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> AddAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn add_assign(&mut self, rhs: Uint<BITS, LIMBS>)
fn add_assign(&mut self, rhs: Uint<BITS, LIMBS>)
Performs the +=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> Arbitrary for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Arbitrary for Uint<BITS, LIMBS>
type Parameters = ()
type Parameters = ()
The type of parameters that arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
. Read more
type Strategy = BoxedStrategy<Uint<BITS, LIMBS>>
type Strategy = BoxedStrategy<Uint<BITS, LIMBS>>
sourcefn arbitrary_with(_: Self::Parameters) -> BoxedStrategy<Self>
fn arbitrary_with(_: Self::Parameters) -> BoxedStrategy<Self>
sourceimpl<'a, const BITS: usize, const LIMBS: usize> Arbitrary<'a> for Uint<BITS, LIMBS>
impl<'a, const BITS: usize, const LIMBS: usize> Arbitrary<'a> for Uint<BITS, LIMBS>
sourcefn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Generate an arbitrary value of Self
from the given unstructured data. Read more
sourcefn size_hint(_depth: usize) -> (usize, Option<usize>)
fn size_hint(_depth: usize) -> (usize, Option<usize>)
Get a size hint for how many bytes out of an Unstructured
this type
needs to construct itself. Read more
sourcefn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Generate an arbitrary value of Self
from the entirety of the given unstructured data. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> BitAnd<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitAnd<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourceimpl<const BITS: usize, const LIMBS: usize> BitAnd<&'_ Uint<BITS, LIMBS>> for &Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitAnd<&'_ Uint<BITS, LIMBS>> for &Uint<BITS, LIMBS>
sourceimpl<const BITS: usize, const LIMBS: usize> BitAndAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitAndAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn bitand_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
fn bitand_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
Performs the &=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> BitAndAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitAndAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn bitand_assign(&mut self, rhs: Uint<BITS, LIMBS>)
fn bitand_assign(&mut self, rhs: Uint<BITS, LIMBS>)
Performs the &=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> BitOr<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitOr<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourceimpl<const BITS: usize, const LIMBS: usize> BitOr<&'_ Uint<BITS, LIMBS>> for &Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitOr<&'_ Uint<BITS, LIMBS>> for &Uint<BITS, LIMBS>
sourceimpl<const BITS: usize, const LIMBS: usize> BitOrAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitOrAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn bitor_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
fn bitor_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
Performs the |=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> BitOrAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitOrAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn bitor_assign(&mut self, rhs: Uint<BITS, LIMBS>)
fn bitor_assign(&mut self, rhs: Uint<BITS, LIMBS>)
Performs the |=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> BitXor<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitXor<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourceimpl<const BITS: usize, const LIMBS: usize> BitXor<&'_ Uint<BITS, LIMBS>> for &Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitXor<&'_ Uint<BITS, LIMBS>> for &Uint<BITS, LIMBS>
sourceimpl<const BITS: usize, const LIMBS: usize> BitXorAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitXorAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn bitxor_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
fn bitxor_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
Performs the ^=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> BitXorAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> BitXorAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn bitxor_assign(&mut self, rhs: Uint<BITS, LIMBS>)
fn bitxor_assign(&mut self, rhs: Uint<BITS, LIMBS>)
Performs the ^=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> Decodable for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Decodable for Uint<BITS, LIMBS>
Allows a Uint
to be deserialized from RLP.
sourceimpl<const BITS: usize, const LIMBS: usize> Decodable for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Decodable for Uint<BITS, LIMBS>
Allows a Uint
to be deserialized from RLP.
sourcefn decode(s: &Rlp<'_>) -> Result<Self, DecoderError>
fn decode(s: &Rlp<'_>) -> Result<Self, DecoderError>
Decode a value from RLP bytes
sourceimpl<'a, const BITS: usize, const LIMBS: usize, DB: Database> Decode<'a, DB> for Uint<BITS, LIMBS> where
Vec<u8>: Decode<'a, DB>,
impl<'a, const BITS: usize, const LIMBS: usize, DB: Database> Decode<'a, DB> for Uint<BITS, LIMBS> where
Vec<u8>: Decode<'a, DB>,
sourcefn decode(value: <DB as HasValueRef<'a>>::ValueRef) -> Result<Self, BoxDynError>
fn decode(value: <DB as HasValueRef<'a>>::ValueRef) -> Result<Self, BoxDynError>
Decode a new value of this type using a raw value from the database.
sourceimpl<'de, const BITS: usize, const LIMBS: usize> Deserialize<'de> for Uint<BITS, LIMBS>
impl<'de, const BITS: usize, const LIMBS: usize> Deserialize<'de> for Uint<BITS, LIMBS>
Deserialize human readable hex strings or byte arrays into hashes.
Hex strings can be upper/lower/mixed case, have an optional 0x
prefix, and
can be any length. They are interpreted big-endian.
sourcefn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> Distribution<Uint<BITS, LIMBS>> for Standard
impl<const BITS: usize, const LIMBS: usize> Distribution<Uint<BITS, LIMBS>> for Standard
sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Uint<BITS, LIMBS>
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Uint<BITS, LIMBS>
Generate a random value of T
, using rng
as the source of randomness.
sourcefn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> DivAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> DivAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn div_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
fn div_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
Performs the /=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> DivAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> DivAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn div_assign(&mut self, rhs: Uint<BITS, LIMBS>)
fn div_assign(&mut self, rhs: Uint<BITS, LIMBS>)
Performs the /=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> Encodable for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Encodable for Uint<BITS, LIMBS>
Allows a Uint
to be serialized as RLP.
sourceimpl<const BITS: usize, const LIMBS: usize> Encodable for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Encodable for Uint<BITS, LIMBS>
Allows a Uint
to be serialized as RLP.
sourceimpl<'a, const BITS: usize, const LIMBS: usize, DB: Database> Encode<'a, DB> for Uint<BITS, LIMBS> where
Vec<u8>: Encode<'a, DB>,
impl<'a, const BITS: usize, const LIMBS: usize, DB: Database> Encode<'a, DB> for Uint<BITS, LIMBS> where
Vec<u8>: Encode<'a, DB>,
sourcefn encode_by_ref(
&self,
buf: &mut <DB as HasArguments<'a>>::ArgumentBuffer
) -> IsNull
fn encode_by_ref(
&self,
buf: &mut <DB as HasArguments<'a>>::ArgumentBuffer
) -> IsNull
Writes the value of self
into buf
without moving self
. Read more
sourcefn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
Writes the value of self
into buf
in the expected format for the database.
fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
sourceimpl From<&'_ BigInteger128> for Uint<128, 2>
impl From<&'_ BigInteger128> for Uint<128, 2>
sourcefn from(value: &BigInteger128) -> Self
fn from(value: &BigInteger128) -> Self
Converts to this type from the input type.
sourceimpl From<&'_ BigInteger256> for Uint<256, 4>
impl From<&'_ BigInteger256> for Uint<256, 4>
sourcefn from(value: &BigInteger256) -> Self
fn from(value: &BigInteger256) -> Self
Converts to this type from the input type.
sourceimpl From<&'_ BigInteger320> for Uint<320, 5>
impl From<&'_ BigInteger320> for Uint<320, 5>
sourcefn from(value: &BigInteger320) -> Self
fn from(value: &BigInteger320) -> Self
Converts to this type from the input type.
sourceimpl From<&'_ BigInteger384> for Uint<384, 6>
impl From<&'_ BigInteger384> for Uint<384, 6>
sourcefn from(value: &BigInteger384) -> Self
fn from(value: &BigInteger384) -> Self
Converts to this type from the input type.
sourceimpl From<&'_ BigInteger448> for Uint<448, 7>
impl From<&'_ BigInteger448> for Uint<448, 7>
sourcefn from(value: &BigInteger448) -> Self
fn from(value: &BigInteger448) -> Self
Converts to this type from the input type.
sourceimpl From<&'_ BigInteger64> for Uint<64, 1>
impl From<&'_ BigInteger64> for Uint<64, 1>
sourcefn from(value: &BigInteger64) -> Self
fn from(value: &BigInteger64) -> Self
Converts to this type from the input type.
sourceimpl From<&'_ BigInteger768> for Uint<768, 12>
impl From<&'_ BigInteger768> for Uint<768, 12>
sourcefn from(value: &BigInteger768) -> Self
fn from(value: &BigInteger768) -> Self
Converts to this type from the input type.
sourceimpl From<&'_ BigInteger832> for Uint<832, 13>
impl From<&'_ BigInteger832> for Uint<832, 13>
sourcefn from(value: &BigInteger832) -> Self
fn from(value: &BigInteger832) -> Self
Converts to this type from the input type.
sourceimpl<P: Fp256Parameters> From<&'_ Fp256<P>> for Uint<256, 4>
impl<P: Fp256Parameters> From<&'_ Fp256<P>> for Uint<256, 4>
sourceimpl<P: Fp320Parameters> From<&'_ Fp320<P>> for Uint<320, 5>
impl<P: Fp320Parameters> From<&'_ Fp320<P>> for Uint<320, 5>
sourceimpl<P: Fp384Parameters> From<&'_ Fp384<P>> for Uint<384, 6>
impl<P: Fp384Parameters> From<&'_ Fp384<P>> for Uint<384, 6>
sourceimpl<P: Fp448Parameters> From<&'_ Fp448<P>> for Uint<448, 7>
impl<P: Fp448Parameters> From<&'_ Fp448<P>> for Uint<448, 7>
sourceimpl<P: Fp64Parameters> From<&'_ Fp64<P>> for Uint<64, 1>
impl<P: Fp64Parameters> From<&'_ Fp64<P>> for Uint<64, 1>
sourceimpl<P: Fp768Parameters> From<&'_ Fp768<P>> for Uint<768, 12>
impl<P: Fp768Parameters> From<&'_ Fp768<P>> for Uint<768, 12>
sourceimpl<P: Fp832Parameters> From<&'_ Fp832<P>> for Uint<832, 13>
impl<P: Fp832Parameters> From<&'_ Fp832<P>> for Uint<832, 13>
sourceimpl From<&'_ Uint<128_usize, 2_usize>> for BigInteger128
impl From<&'_ Uint<128_usize, 2_usize>> for BigInteger128
sourceimpl From<&'_ Uint<256_usize, 4_usize>> for BigInteger256
impl From<&'_ Uint<256_usize, 4_usize>> for BigInteger256
sourceimpl From<&'_ Uint<320_usize, 5_usize>> for BigInteger320
impl From<&'_ Uint<320_usize, 5_usize>> for BigInteger320
sourceimpl From<&'_ Uint<384_usize, 6_usize>> for BigInteger384
impl From<&'_ Uint<384_usize, 6_usize>> for BigInteger384
sourceimpl From<&'_ Uint<448_usize, 7_usize>> for BigInteger448
impl From<&'_ Uint<448_usize, 7_usize>> for BigInteger448
sourceimpl From<&'_ Uint<64_usize, 1_usize>> for BigInteger64
impl From<&'_ Uint<64_usize, 1_usize>> for BigInteger64
sourceimpl From<&'_ Uint<768_usize, 12_usize>> for BigInteger768
impl From<&'_ Uint<768_usize, 12_usize>> for BigInteger768
sourceimpl From<&'_ Uint<832_usize, 13_usize>> for BigInteger832
impl From<&'_ Uint<832_usize, 13_usize>> for BigInteger832
sourceimpl From<BigInteger128> for Uint<128, 2>
impl From<BigInteger128> for Uint<128, 2>
sourcefn from(value: BigInteger128) -> Self
fn from(value: BigInteger128) -> Self
Converts to this type from the input type.
sourceimpl From<BigInteger256> for Uint<256, 4>
impl From<BigInteger256> for Uint<256, 4>
sourcefn from(value: BigInteger256) -> Self
fn from(value: BigInteger256) -> Self
Converts to this type from the input type.
sourceimpl From<BigInteger320> for Uint<320, 5>
impl From<BigInteger320> for Uint<320, 5>
sourcefn from(value: BigInteger320) -> Self
fn from(value: BigInteger320) -> Self
Converts to this type from the input type.
sourceimpl From<BigInteger384> for Uint<384, 6>
impl From<BigInteger384> for Uint<384, 6>
sourcefn from(value: BigInteger384) -> Self
fn from(value: BigInteger384) -> Self
Converts to this type from the input type.
sourceimpl From<BigInteger448> for Uint<448, 7>
impl From<BigInteger448> for Uint<448, 7>
sourcefn from(value: BigInteger448) -> Self
fn from(value: BigInteger448) -> Self
Converts to this type from the input type.
sourceimpl From<BigInteger64> for Uint<64, 1>
impl From<BigInteger64> for Uint<64, 1>
sourcefn from(value: BigInteger64) -> Self
fn from(value: BigInteger64) -> Self
Converts to this type from the input type.
sourceimpl From<BigInteger768> for Uint<768, 12>
impl From<BigInteger768> for Uint<768, 12>
sourcefn from(value: BigInteger768) -> Self
fn from(value: BigInteger768) -> Self
Converts to this type from the input type.
sourceimpl From<BigInteger832> for Uint<832, 13>
impl From<BigInteger832> for Uint<832, 13>
sourcefn from(value: BigInteger832) -> Self
fn from(value: BigInteger832) -> Self
Converts to this type from the input type.
sourceimpl<P: Fp256Parameters> From<Fp256<P>> for Uint<256, 4>
impl<P: Fp256Parameters> From<Fp256<P>> for Uint<256, 4>
sourceimpl<P: Fp320Parameters> From<Fp320<P>> for Uint<320, 5>
impl<P: Fp320Parameters> From<Fp320<P>> for Uint<320, 5>
sourceimpl<P: Fp384Parameters> From<Fp384<P>> for Uint<384, 6>
impl<P: Fp384Parameters> From<Fp384<P>> for Uint<384, 6>
sourceimpl<P: Fp448Parameters> From<Fp448<P>> for Uint<448, 7>
impl<P: Fp448Parameters> From<Fp448<P>> for Uint<448, 7>
sourceimpl<P: Fp64Parameters> From<Fp64<P>> for Uint<64, 1>
impl<P: Fp64Parameters> From<Fp64<P>> for Uint<64, 1>
sourceimpl<P: Fp768Parameters> From<Fp768<P>> for Uint<768, 12>
impl<P: Fp768Parameters> From<Fp768<P>> for Uint<768, 12>
sourceimpl<P: Fp832Parameters> From<Fp832<P>> for Uint<832, 13>
impl<P: Fp832Parameters> From<Fp832<P>> for Uint<832, 13>
sourceimpl From<Uint<128_usize, 2_usize>> for BigInteger128
impl From<Uint<128_usize, 2_usize>> for BigInteger128
sourceimpl From<Uint<256_usize, 4_usize>> for BigInteger256
impl From<Uint<256_usize, 4_usize>> for BigInteger256
sourceimpl From<Uint<320_usize, 5_usize>> for BigInteger320
impl From<Uint<320_usize, 5_usize>> for BigInteger320
sourceimpl From<Uint<384_usize, 6_usize>> for BigInteger384
impl From<Uint<384_usize, 6_usize>> for BigInteger384
sourceimpl From<Uint<448_usize, 7_usize>> for BigInteger448
impl From<Uint<448_usize, 7_usize>> for BigInteger448
sourceimpl From<Uint<64_usize, 1_usize>> for BigInteger64
impl From<Uint<64_usize, 1_usize>> for BigInteger64
sourceimpl From<Uint<768_usize, 12_usize>> for BigInteger768
impl From<Uint<768_usize, 12_usize>> for BigInteger768
sourceimpl From<Uint<832_usize, 13_usize>> for BigInteger832
impl From<Uint<832_usize, 13_usize>> for BigInteger832
sourceimpl<'a, const BITS: usize, const LIMBS: usize> FromSql<'a> for Uint<BITS, LIMBS>
impl<'a, const BITS: usize, const LIMBS: usize> FromSql<'a> for Uint<BITS, LIMBS>
Convert from Postgres types.
See ToSql
for details.
sourcefn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Determines if a value of this type can be created from the specified
Postgres Type
. Read more
sourcefn from_sql(
ty: &Type,
raw: &'a [u8]
) -> Result<Self, Box<dyn Error + Sync + Send>>
fn from_sql(
ty: &Type,
raw: &'a [u8]
) -> Result<Self, Box<dyn Error + Sync + Send>>
Creates a new value of this type from a buffer of data of the specified
Postgres Type
in its binary format. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> MulAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> MulAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn mul_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
fn mul_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
Performs the *=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> MulAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> MulAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn mul_assign(&mut self, rhs: Uint<BITS, LIMBS>)
fn mul_assign(&mut self, rhs: Uint<BITS, LIMBS>)
Performs the *=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> Ord for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Ord for Uint<BITS, LIMBS>
sourceimpl<const BITS: usize, const LIMBS: usize> PartialEq<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> PartialEq<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourceimpl<const BITS: usize, const LIMBS: usize> PartialOrd<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> PartialOrd<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<'a, const BITS: usize, const LIMBS: usize> Product<&'a Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<'a, const BITS: usize, const LIMBS: usize> Product<&'a Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourceimpl<const BITS: usize, const LIMBS: usize> RemAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> RemAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn rem_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
fn rem_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
Performs the %=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> RemAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> RemAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn rem_assign(&mut self, rhs: Uint<BITS, LIMBS>)
fn rem_assign(&mut self, rhs: Uint<BITS, LIMBS>)
Performs the %=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> Serialize for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Serialize for Uint<BITS, LIMBS>
Serialize a Uint
value.
For human readable formats a 0x
prefixed lower case hex string is used.
For binary formats a byte array is used. Leading zeros are included.
sourceimpl<const BITS: usize, const LIMBS: usize> ShlAssign<&'_ usize> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> ShlAssign<&'_ usize> for Uint<BITS, LIMBS>
sourcefn shl_assign(&mut self, rhs: &usize)
fn shl_assign(&mut self, rhs: &usize)
Performs the <<=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> ShlAssign<usize> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> ShlAssign<usize> for Uint<BITS, LIMBS>
sourcefn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
Performs the <<=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> ShrAssign<&'_ usize> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> ShrAssign<&'_ usize> for Uint<BITS, LIMBS>
sourcefn shr_assign(&mut self, rhs: &usize)
fn shr_assign(&mut self, rhs: &usize)
Performs the >>=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> ShrAssign<usize> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> ShrAssign<usize> for Uint<BITS, LIMBS>
sourcefn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
Performs the >>=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> SubAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> SubAssign<&'_ Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn sub_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
fn sub_assign(&mut self, rhs: &Uint<BITS, LIMBS>)
Performs the -=
operation. Read more
sourceimpl<const BITS: usize, const LIMBS: usize> SubAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> SubAssign<Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourcefn sub_assign(&mut self, rhs: Uint<BITS, LIMBS>)
fn sub_assign(&mut self, rhs: Uint<BITS, LIMBS>)
Performs the -=
operation. Read more
sourceimpl<'a, const BITS: usize, const LIMBS: usize> Sum<&'a Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
impl<'a, const BITS: usize, const LIMBS: usize> Sum<&'a Uint<BITS, LIMBS>> for Uint<BITS, LIMBS>
sourceimpl<const BITS: usize, const LIMBS: usize> ToSql for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> ToSql for Uint<BITS, LIMBS>
Convert to Postgres types.
Compatible Postgres data types are:
BOOL
,SMALLINT
,INTEGER
,BIGINT
which are 1, 16, 32 and 64 bit signed integers respectively.OID
which is a 32 bit unsigned integer.FLOAT
,DOUBLE PRECISION
which are 32 and 64 bit floating point.DECIMAL
andNUMERIC
, which are variable length.MONEY
which is a 64 bit integer with two decimals.BYTEA
,BIT
,VARBIT
interpreted as a big-endian binary number.CHAR
,VARCHAR
,TEXT
as0x
-prefixed big-endian hex strings.JSON
,JSONB
as a hex string compatible with the Serde serialization.
Note: Uint
s are never null, use Option<Uint>
instead.
Errors
Returns an error when trying to convert to a value that is too small to fit
the number. Note that this depends on the value, not the type, so a
Uint<256>
can be stored in a SMALLINT
column, as long as the values
are less than $2^{16}$.
Implementation details
The Postgres binary formats are used in the wire-protocol and the
the COPY BINARY
command, but they have very little documentation. You are
pointed to the source code, for example this is the implementation of the
the NUMERIC
type serializer: numeric.c
.
sourcefn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Determines if a value of this type can be converted to the specified
Postgres Type
. Read more
sourceimpl<P: Fp256Parameters> TryFrom<&'_ Uint<256_usize, 4_usize>> for Fp256<P>
impl<P: Fp256Parameters> TryFrom<&'_ Uint<256_usize, 4_usize>> for Fp256<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: &Uint<256, 4>) -> Result<Self, ToFieldError>
fn try_from(value: &Uint<256, 4>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp320Parameters> TryFrom<&'_ Uint<320_usize, 5_usize>> for Fp320<P>
impl<P: Fp320Parameters> TryFrom<&'_ Uint<320_usize, 5_usize>> for Fp320<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: &Uint<320, 5>) -> Result<Self, ToFieldError>
fn try_from(value: &Uint<320, 5>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp384Parameters> TryFrom<&'_ Uint<384_usize, 6_usize>> for Fp384<P>
impl<P: Fp384Parameters> TryFrom<&'_ Uint<384_usize, 6_usize>> for Fp384<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: &Uint<384, 6>) -> Result<Self, ToFieldError>
fn try_from(value: &Uint<384, 6>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp448Parameters> TryFrom<&'_ Uint<448_usize, 7_usize>> for Fp448<P>
impl<P: Fp448Parameters> TryFrom<&'_ Uint<448_usize, 7_usize>> for Fp448<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: &Uint<448, 7>) -> Result<Self, ToFieldError>
fn try_from(value: &Uint<448, 7>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp64Parameters> TryFrom<&'_ Uint<64_usize, 1_usize>> for Fp64<P>
impl<P: Fp64Parameters> TryFrom<&'_ Uint<64_usize, 1_usize>> for Fp64<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: &Uint<64, 1>) -> Result<Self, ToFieldError>
fn try_from(value: &Uint<64, 1>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp768Parameters> TryFrom<&'_ Uint<768_usize, 12_usize>> for Fp768<P>
impl<P: Fp768Parameters> TryFrom<&'_ Uint<768_usize, 12_usize>> for Fp768<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: &Uint<768, 12>) -> Result<Self, ToFieldError>
fn try_from(value: &Uint<768, 12>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp832Parameters> TryFrom<&'_ Uint<832_usize, 13_usize>> for Fp832<P>
impl<P: Fp832Parameters> TryFrom<&'_ Uint<832_usize, 13_usize>> for Fp832<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: &Uint<832, 13>) -> Result<Self, ToFieldError>
fn try_from(value: &Uint<832, 13>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp256Parameters> TryFrom<Uint<256_usize, 4_usize>> for Fp256<P>
impl<P: Fp256Parameters> TryFrom<Uint<256_usize, 4_usize>> for Fp256<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: Uint<256, 4>) -> Result<Self, ToFieldError>
fn try_from(value: Uint<256, 4>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp320Parameters> TryFrom<Uint<320_usize, 5_usize>> for Fp320<P>
impl<P: Fp320Parameters> TryFrom<Uint<320_usize, 5_usize>> for Fp320<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: Uint<320, 5>) -> Result<Self, ToFieldError>
fn try_from(value: Uint<320, 5>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp384Parameters> TryFrom<Uint<384_usize, 6_usize>> for Fp384<P>
impl<P: Fp384Parameters> TryFrom<Uint<384_usize, 6_usize>> for Fp384<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: Uint<384, 6>) -> Result<Self, ToFieldError>
fn try_from(value: Uint<384, 6>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp448Parameters> TryFrom<Uint<448_usize, 7_usize>> for Fp448<P>
impl<P: Fp448Parameters> TryFrom<Uint<448_usize, 7_usize>> for Fp448<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: Uint<448, 7>) -> Result<Self, ToFieldError>
fn try_from(value: Uint<448, 7>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp64Parameters> TryFrom<Uint<64_usize, 1_usize>> for Fp64<P>
impl<P: Fp64Parameters> TryFrom<Uint<64_usize, 1_usize>> for Fp64<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: Uint<64, 1>) -> Result<Self, ToFieldError>
fn try_from(value: Uint<64, 1>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp768Parameters> TryFrom<Uint<768_usize, 12_usize>> for Fp768<P>
impl<P: Fp768Parameters> TryFrom<Uint<768_usize, 12_usize>> for Fp768<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: Uint<768, 12>) -> Result<Self, ToFieldError>
fn try_from(value: Uint<768, 12>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<P: Fp832Parameters> TryFrom<Uint<832_usize, 13_usize>> for Fp832<P>
impl<P: Fp832Parameters> TryFrom<Uint<832_usize, 13_usize>> for Fp832<P>
type Error = ToFieldError
type Error = ToFieldError
The type returned in the event of a conversion error.
sourcefn try_from(value: Uint<832, 13>) -> Result<Self, ToFieldError>
fn try_from(value: Uint<832, 13>) -> Result<Self, ToFieldError>
Performs the conversion.
sourceimpl<const BITS: usize, const LIMBS: usize, DB: Database> Type<DB> for Uint<BITS, LIMBS> where
Vec<u8>: Type<DB>,
impl<const BITS: usize, const LIMBS: usize, DB: Database> Type<DB> for Uint<BITS, LIMBS> where
Vec<u8>: Type<DB>,
impl<const BITS: usize, const LIMBS: usize> Copy for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Eq for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> StructuralEq for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> StructuralPartialEq for Uint<BITS, LIMBS>
Auto Trait Implementations
impl<const BITS: usize, const LIMBS: usize> RefUnwindSafe for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Send for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Sync for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> Unpin for Uint<BITS, LIMBS>
impl<const BITS: usize, const LIMBS: usize> UnwindSafe for Uint<BITS, LIMBS>
Blanket Implementations
impl<T> AsRelative for T where
T: Into<f64>,
impl<T> AsRelative for T where
T: Into<f64>,
fn percent_width(self) -> RelativeSize
fn percent_width(self) -> RelativeSize
Make the value a relative size of percentage of width
fn percent_height(self) -> RelativeSize
fn percent_height(self) -> RelativeSize
Make the value a relative size of percentage of height
fn percent(self) -> RelativeSize
fn percent(self) -> RelativeSize
Make the value a relative size of percentage of minimal of height and width
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> BorrowToSql for T where
T: ToSql,
impl<T> BorrowToSql for T where
T: ToSql,
sourcefn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
Returns a reference to self
as a ToSql
trait object.