alloy_primitives

Struct Signed

Source
pub struct Signed<const BITS: usize, const LIMBS: usize>(/* private fields */);
Expand description

Signed integer wrapping a ruint::Uint.

This signed integer implementation is fully abstract across the number of bits. It wraps a ruint::Uint, and co-opts the most significant bit to represent the sign. The number is represented in two’s complement, using the underlying Uint’s u64 limbs. The limbs can be accessed via the Signed::as_limbs() method, and are least-significant first.

§Aliases

We provide aliases for every bit-width divisble by 8, from 8 to 256. These are located in crate::aliases and are named I256, I248 etc. Most users will want crate::I256.

§Usage

// Instantiate from a number
let a = I256::unchecked_from(1);
// Use `try_from` if you're not sure it'll fit
let b = I256::try_from(200000382).unwrap();

// Or parse from a string :)
let c = "100".parse::<I256>().unwrap();
let d = "-0x138f".parse::<I256>().unwrap();

// Preceding plus is allowed but not recommended
let e = "+0xdeadbeef".parse::<I256>().unwrap();

// Underscores are ignored
let f = "1_000_000".parse::<I256>().unwrap();

// But invalid chars are not
assert!("^31".parse::<I256>().is_err());

// Math works great :)
let g = a * b + c - d;

// And so do comparisons!
assert!(e > a);

// We have some useful constants too
assert_eq!(I256::ZERO, I256::unchecked_from(0));
assert_eq!(I256::ONE, I256::unchecked_from(1));
assert_eq!(I256::MINUS_ONE, I256::unchecked_from(-1));

Implementations§

Source§

impl<const BITS: usize, const LIMBS: usize> Signed<BITS, LIMBS>

Source

pub const fn low_u8(&self) -> u8

Low word.

Source

pub fn as_u8(&self) -> u8

Conversion to u8 with overflow checking.

§Panics

Panics if the number is outside the u8 valid range.

Source

pub const fn low_i8(&self) -> i8

Low word.

Source

pub fn as_i8(&self) -> i8

Conversion to i8 with overflow checking.

§Panics

Panics if the number is outside the i8 valid range.

Source

pub const fn low_u16(&self) -> u16

Low word.

Source

pub fn as_u16(&self) -> u16

Conversion to u16 with overflow checking.

§Panics

Panics if the number is outside the u16 valid range.

Source

pub const fn low_i16(&self) -> i16

Low word.

Source

pub fn as_i16(&self) -> i16

Conversion to i16 with overflow checking.

§Panics

Panics if the number is outside the i16 valid range.

Source

pub const fn low_u32(&self) -> u32

Low word.

Source

pub fn as_u32(&self) -> u32

Conversion to u32 with overflow checking.

§Panics

Panics if the number is outside the u32 valid range.

Source

pub const fn low_i32(&self) -> i32

Low word.

Source

pub fn as_i32(&self) -> i32

Conversion to i32 with overflow checking.

§Panics

Panics if the number is outside the i32 valid range.

Source

pub const fn low_u64(&self) -> u64

Low word.

Source

pub fn as_u64(&self) -> u64

Conversion to u64 with overflow checking.

§Panics

Panics if the number is outside the u64 valid range.

Source

pub const fn low_i64(&self) -> i64

Low word.

Source

pub fn as_i64(&self) -> i64

Conversion to i64 with overflow checking.

§Panics

Panics if the number is outside the i64 valid range.

Source

pub const fn low_usize(&self) -> usize

Low word.

Source

pub fn as_usize(&self) -> usize

Conversion to usize with overflow checking.

§Panics

Panics if the number is outside the usize valid range.

Source

pub const fn low_isize(&self) -> isize

Low word.

Source

pub fn as_isize(&self) -> isize

Conversion to isize with overflow checking.

§Panics

Panics if the number is outside the isize valid range.

Source§

impl<const BITS: usize, const LIMBS: usize> Signed<BITS, LIMBS>

Source

pub const BITS: usize = BITS

Number of bits.

Source

pub const BYTES: usize = Uint<BITS, LIMBS>::BYTES

The size of this integer type in bytes. Note that some bits may be forced zero if BITS is not cleanly divisible by eight.

Source

pub const MIN: Self = _

The minimum value.

Source

pub const MAX: Self = _

The maximum value.

Source

pub const ZERO: Self = _

Zero (additive identity) of this type.

Source

pub const ONE: Self = _

One (multiplicative identity) of this type.

Source

pub const MINUS_ONE: Self = _

Minus one (multiplicative inverse) of this type.

Source

pub const fn from_raw(val: Uint<BITS, LIMBS>) -> Self

Coerces an unsigned integer into a signed one. If the unsigned integer is greater than or equal to 1 << 255, then the result will overflow into a negative value.

Source

pub fn unchecked_from<T>(val: T) -> Self
where T: TryInto<Self>, <T as TryInto<Self>>::Error: Debug,

Shortcut for val.try_into().unwrap().

§Panics

Panics if the conversion fails.

Source

pub fn unchecked_into<T>(self) -> T
where Self: TryInto<T>, <Self as TryInto<T>>::Error: Debug,

Shortcut for self.try_into().unwrap().

§Panics

Panics if the conversion fails.

Source

pub const fn into_raw(self) -> Uint<BITS, LIMBS>

Returns the signed integer as a unsigned integer. If the value of self negative, then the two’s complement of its absolute value will be returned.

Source

pub const fn sign(&self) -> Sign

Returns the sign of self.

Source

pub const fn is_odd(&self) -> bool

Determines if the integer is odd.

Source

pub const fn const_eq(&self, other: &Self) -> bool

Compile-time equality. NOT constant-time equality.

Source

pub const fn is_zero(&self) -> bool

Returns true if self is zero and false if the number is negative or positive.

Source

pub const fn is_positive(&self) -> bool

Returns true if self is positive and false if the number is zero or negative.

Source

pub const fn is_negative(&self) -> bool

Returns true if self is negative and false if the number is zero or positive.

Source

pub fn count_ones(&self) -> usize

Returns the number of ones in the binary representation of self.

Source

pub fn count_zeros(&self) -> usize

Returns the number of zeros in the binary representation of self.

Source

pub fn leading_zeros(&self) -> usize

Returns the number of leading zeros in the binary representation of self.

Source

pub fn trailing_zeros(&self) -> usize

Returns the number of leading zeros in the binary representation of self.

Source

pub fn trailing_ones(&self) -> usize

Returns the number of leading ones in the binary representation of self.

Source

pub const fn bit(&self, index: usize) -> bool

Returns whether a specific bit is set.

Returns false if index exceeds the bit width of the number.

Source

pub const fn byte(&self, index: usize) -> u8

Returns a specific byte. The byte at index 0 is the least significant byte (little endian).

§Panics

Panics if index exceeds the byte width of the number.

Source

pub fn bits(&self) -> u32

Return the least number of bits needed to represent the number.

Source

pub fn overflowing_from_sign_and_abs( sign: Sign, abs: Uint<BITS, LIMBS>, ) -> (Self, bool)

Creates a Signed from a sign and an absolute value. Returns the value and a bool that is true if the conversion caused an overflow.

Source

pub fn checked_from_sign_and_abs( sign: Sign, abs: Uint<BITS, LIMBS>, ) -> Option<Self>

Creates a Signed from an absolute value and a negative flag. Returns None if it would overflow as Signed.

Source

pub fn from_dec_str(value: &str) -> Result<Self, ParseSignedError>

Convert from a decimal string.

Source

pub fn to_dec_string(&self) -> String

Convert to a decimal string.

Source

pub fn from_hex_str(value: &str) -> Result<Self, ParseSignedError>

Convert from a hex string.

Source

pub fn to_hex_string(&self) -> String

Convert to a hex string.

Source

pub fn into_sign_and_abs(&self) -> (Sign, Uint<BITS, LIMBS>)

Splits a Signed into its absolute value and negative flag.

Source

pub const fn to_be_bytes<const BYTES: usize>(&self) -> [u8; BYTES]

Converts self 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.

Source

pub const fn to_le_bytes<const BYTES: usize>(&self) -> [u8; BYTES]

Converts self 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.

Source

pub const fn from_be_bytes<const BYTES: usize>(bytes: [u8; BYTES]) -> Self

Converts 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.

Panics if the value is too large for the bit-size of the Uint.

Source

pub const fn from_le_bytes<const BYTES: usize>(bytes: [u8; BYTES]) -> Self

Convert from an array in LE format

§Panics

Panics if the given array is not the correct length.

Source

pub fn try_from_be_slice(slice: &[u8]) -> Option<Self>

Creates a new integer from a big endian slice of bytes.

The slice is interpreted as a big endian number. Leading zeros are ignored. The slice can be any length.

Returns None if the value is larger than fits the Uint.

Source

pub fn try_from_le_slice(slice: &[u8]) -> Option<Self>

Creates a new integer from a little endian slice of bytes.

The slice is interpreted as a big endian number. Leading zeros are ignored. The slice can be any length.

Returns None if the value is larger than fits the Uint.

Source

pub const fn as_limbs(&self) -> &[u64; LIMBS]

View the array of limbs.

Source

pub const fn into_limbs(self) -> [u64; LIMBS]

Convert to a array of limbs.

Limbs are least significant first.

Source

pub const fn from_limbs(limbs: [u64; LIMBS]) -> Self

Construct a new integer from little-endian a array of limbs.

§Panics

Panics if LIMBS is not equal to nlimbs(BITS).

Panics if the value is to large for the bit-size of the Uint.

Source

pub fn from_base_be<I: IntoIterator<Item = u64>>( base: u64, digits: I, ) -> Result<Self, BaseConvertError>

Constructs the Signed from digits in the base base in big-endian. Wrapper around ruint’s from_base_be

§Errors
Source§

impl<const BITS: usize, const LIMBS: usize> Signed<BITS, LIMBS>

Source

pub fn abs(self) -> Self

Computes the absolute value of self.

§Overflow behavior

The absolute value of Self::MIN cannot be represented as Self and attempting to calculate it will cause an overflow. This means that code in debug mode will trigger a panic on this case and optimized code will return Self::MIN without a panic.

Source

pub fn overflowing_abs(self) -> (Self, bool)

Computes the absolute value of self.

Returns a tuple of the absolute version of self along with a boolean indicating whether an overflow happened. If self is the minimum value then the minimum value will be returned again and true will be returned for an overflow happening.

Source

pub fn checked_abs(self) -> Option<Self>

Checked absolute value. Computes self.abs(), returning None if self == MIN.

Source

pub fn saturating_abs(self) -> Self

Saturating absolute value. Computes self.abs(), returning MAX if self == MIN instead of overflowing.

Source

pub fn wrapping_abs(self) -> Self

Wrapping absolute value. Computes self.abs(), wrapping around at the boundary of the type.

Source

pub fn unsigned_abs(self) -> Uint<BITS, LIMBS>

Computes the absolute value of self without any wrapping or panicking.

Source

pub fn overflowing_neg(self) -> (Self, bool)

Negates self, overflowing if this is equal to the minimum value.

Returns a tuple of the negated version of self along with a boolean indicating whether an overflow happened. If self is the minimum value, then the minimum value will be returned again and true will be returned for an overflow happening.

Source

pub fn checked_neg(self) -> Option<Self>

Checked negation. Computes -self, returning None if self == MIN.

Source

pub fn saturating_neg(self) -> Self

Saturating negation. Computes -self, returning MAX if self == MIN instead of overflowing.

Source

pub fn wrapping_neg(self) -> Self

Wrapping (modular) negation. Computes -self, wrapping around at the boundary of the type.

The only case where such wrapping can occur is when one negates MIN on a signed type (where MIN is the negative minimal value for the type); this is a positive value that is too large to represent in the type. In such a case, this function returns MIN itself.

Source

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.

Source

pub const fn checked_add(self, rhs: Self) -> Option<Self>

Checked integer addition. Computes self + rhs, returning None if overflow occurred.

Source

pub const fn saturating_add(self, rhs: Self) -> Self

Saturating integer addition. Computes self + rhs, saturating at the numeric bounds instead of overflowing.

Source

pub const fn wrapping_add(self, rhs: Self) -> Self

Wrapping (modular) addition. Computes self + rhs, wrapping around at the boundary of the type.

Source

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.

Source

pub const fn checked_sub(self, rhs: Self) -> Option<Self>

Checked integer subtraction. Computes self - rhs, returning None if overflow occurred.

Source

pub const fn saturating_sub(self, rhs: Self) -> Self

Saturating integer subtraction. Computes self - rhs, saturating at the numeric bounds instead of overflowing.

Source

pub const fn wrapping_sub(self, rhs: Self) -> Self

Wrapping (modular) subtraction. Computes self - rhs, wrapping around at the boundary of the type.

Source

pub fn overflowing_mul(self, rhs: Self) -> (Self, bool)

Calculates self * 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.

Source

pub fn checked_mul(self, rhs: Self) -> Option<Self>

Checked integer multiplication. Computes self * rhs, returning None if overflow occurred.

Source

pub fn saturating_mul(self, rhs: Self) -> Self

Saturating integer multiplication. Computes self * rhs, saturating at the numeric bounds instead of overflowing.

Source

pub fn wrapping_mul(self, rhs: Self) -> Self

Wrapping (modular) multiplication. Computes self * rhs, wrapping around at the boundary of the type.

Source

pub fn overflowing_div(self, rhs: Self) -> (Self, bool)

Calculates self / rhs

Returns a tuple of the divisor along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would occur then self is returned.

§Panics

If rhs is 0.

Source

pub fn checked_div(self, rhs: Self) -> Option<Self>

Checked integer division. Computes self / rhs, returning None if rhs == 0 or the division results in overflow.

Source

pub fn saturating_div(self, rhs: Self) -> Self

Saturating integer division. Computes self / rhs, saturating at the numeric bounds instead of overflowing.

§Panics

If rhs is 0.

Source

pub fn wrapping_div(self, rhs: Self) -> Self

Wrapping (modular) division. Computes self / rhs, wrapping around at the boundary of the type.

The only case where such wrapping can occur is when one divides MIN / -1 on a signed type (where MIN is the negative minimal value for the type); this is equivalent to -MIN, a positive value that is too large to represent in the type. In such a case, this function returns MIN itself.

§Panics

If rhs is 0.

Source

pub fn overflowing_rem(self, rhs: Self) -> (Self, bool)

Calculates self % rhs

Returns a tuple of the remainder after dividing along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would occur then 0 is returned.

§Panics

If rhs is 0.

Source

pub fn checked_rem(self, rhs: Self) -> Option<Self>

Checked integer remainder. Computes self % rhs, returning None if rhs == 0 or the division results in overflow.

Source

pub fn wrapping_rem(self, rhs: Self) -> Self

Wrapping (modular) remainder. Computes self % rhs, wrapping around at the boundary of the type.

Such wrap-around never actually occurs mathematically; implementation artifacts make x % y invalid for MIN / -1 on a signed type (where MIN is the negative minimal value). In such a case, this function returns 0.

§Panics

If rhs is 0.

Source

pub fn div_euclid(self, rhs: Self) -> Self

Calculates the quotient of Euclidean division of self by rhs.

This computes the integer q such that self = q * rhs + r, with r = self.rem_euclid(rhs) and 0 <= r < abs(rhs).

In other words, the result is self / rhs rounded to the integer q such that self >= q * rhs. If self > 0, this is equal to round towards zero (the default in Rust); if self < 0, this is equal to round towards +/- infinity.

§Panics

If rhs is 0 or the division results in overflow.

Source

pub fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)

Calculates the quotient of Euclidean division self.div_euclid(rhs).

Returns a tuple of the divisor along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would occur then self is returned.

§Panics

If rhs is 0.

Source

pub fn checked_div_euclid(self, rhs: Self) -> Option<Self>

Checked Euclidean division. Computes self.div_euclid(rhs), returning None if rhs == 0 or the division results in overflow.

Source

pub fn wrapping_div_euclid(self, rhs: Self) -> Self

Wrapping Euclidean division. Computes self.div_euclid(rhs), wrapping around at the boundary of the type.

Wrapping will only occur in MIN / -1 on a signed type (where MIN is the negative minimal value for the type). This is equivalent to -MIN, a positive value that is too large to represent in the type. In this case, this method returns MIN itself.

§Panics

If rhs is 0.

Source

pub fn rem_euclid(self, rhs: Self) -> Self

Calculates the least nonnegative remainder of self (mod rhs).

This is done as if by the Euclidean division algorithm – given r = self.rem_euclid(rhs), self = rhs * self.div_euclid(rhs) + r, and 0 <= r < abs(rhs).

§Panics

If rhs is 0 or the division results in overflow.

Source

pub fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool)

Overflowing Euclidean remainder. Calculates self.rem_euclid(rhs).

Returns a tuple of the remainder after dividing along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would occur then 0 is returned.

§Panics

If rhs is 0.

Source

pub fn wrapping_rem_euclid(self, rhs: Self) -> Self

Wrapping Euclidean remainder. Computes self.rem_euclid(rhs), wrapping around at the boundary of the type.

Wrapping will only occur in MIN % -1 on a signed type (where MIN is the negative minimal value for the type). In this case, this method returns 0.

§Panics

If rhs is 0.

Source

pub fn checked_rem_euclid(self, rhs: Self) -> Option<Self>

Checked Euclidean remainder. Computes self.rem_euclid(rhs), returning None if rhs == 0 or the division results in overflow.

Source

pub fn exp10(n: usize) -> Self

Create 10**n as this type.

§Panics

If the result overflows the type.

Source

pub fn pow(self, exp: Uint<BITS, LIMBS>) -> Self

Raises self to the power of exp, using exponentiation by squaring.

§Panics

If the result overflows the type in debug mode.

Source

pub fn overflowing_pow(self, exp: Uint<BITS, LIMBS>) -> (Self, bool)

Raises self to the power of exp, using exponentiation by squaring.

Returns a tuple of the exponentiation along with a bool indicating whether an overflow happened.

Source

pub fn checked_pow(self, exp: Uint<BITS, LIMBS>) -> Option<Self>

Checked exponentiation. Computes self.pow(exp), returning None if overflow occurred.

Source

pub fn saturating_pow(self, exp: Uint<BITS, LIMBS>) -> Self

Saturating integer exponentiation. Computes self.pow(exp), saturating at the numeric bounds instead of overflowing.

Source

pub fn wrapping_pow(self, exp: Uint<BITS, LIMBS>) -> Self

Raises self to the power of exp, wrapping around at the boundary of the type.

Source

pub fn overflowing_shl(self, rhs: usize) -> (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.

Source

pub fn checked_shl(self, rhs: usize) -> Option<Self>

Checked shift left. Computes self << rhs, returning None if rhs is larger than or equal to the number of bits in self.

Source

pub fn wrapping_shl(self, rhs: usize) -> Self

Wrapping shift left. Computes self << rhs, returning 0 if larger than or equal to the number of bits in self.

Source

pub fn overflowing_shr(self, rhs: usize) -> (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.

Source

pub fn checked_shr(self, rhs: usize) -> Option<Self>

Checked shift right. Computes self >> rhs, returning None if rhs is larger than or equal to the number of bits in self.

Source

pub fn wrapping_shr(self, rhs: usize) -> Self

Wrapping shift right. Computes self >> rhs, returning 0 if larger than or equal to the number of bits in self.

Source

pub fn asr(self, rhs: usize) -> Self

Arithmetic shift right operation. Computes self >> rhs maintaining the original sign. If the number is positive this is the same as logic shift right.

Source

pub fn asl(self, rhs: usize) -> Option<Self>

Arithmetic shift left operation. Computes self << rhs, checking for overflow on the final result.

Returns None if the operation overflowed (most significant bit changes).

Source

pub fn twos_complement(self) -> Uint<BITS, LIMBS>

Compute the two’s complement of this number.

Trait Implementations§

Source§

impl<T, const BITS: usize, const LIMBS: usize> Add<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<T, const BITS: usize, const LIMBS: usize> AddAssign<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl<'arbitrary, const BITS: usize, const LIMBS: usize> Arbitrary<'arbitrary> for Signed<BITS, LIMBS>

Source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

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
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Arbitrary for Signed<BITS, LIMBS>

Source§

type Parameters = <Uint<BITS, LIMBS> as Arbitrary>::Parameters

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
Source§

type Strategy = Map<<Uint<BITS, LIMBS> as Arbitrary>::Strategy, fn(_: Uint<BITS, LIMBS>) -> Signed<BITS, LIMBS>>

The type of Strategy used to generate values of type Self.
Source§

fn arbitrary_with(_top: Self::Parameters) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
Source§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Binary for Signed<BITS, LIMBS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitAnd for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitAndAssign for Signed<BITS, LIMBS>

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitOr for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitOrAssign for Signed<BITS, LIMBS>

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitXor for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> BitXorAssign for Signed<BITS, LIMBS>

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Clone for Signed<BITS, LIMBS>

Source§

fn clone(&self) -> Signed<BITS, LIMBS>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Debug for Signed<BITS, LIMBS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Default for Signed<BITS, LIMBS>

Source§

fn default() -> Signed<BITS, LIMBS>

Returns the “default value” for a type. Read more
Source§

impl<'de, const BITS: usize, const LIMBS: usize> Deserialize<'de> for Signed<BITS, LIMBS>

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Display for Signed<BITS, LIMBS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, const BITS: usize, const LIMBS: usize> Div<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T, const BITS: usize, const LIMBS: usize> DivAssign<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl From<Signed<128, 2>> for B128

Source§

fn from(value: I128) -> Self

Converts a fixed-width unsigned integer into a fixed byte array by interpreting the bytes as big-endian.

Source§

impl From<Signed<16, 1>> for B16

Source§

fn from(value: I16) -> Self

Converts a fixed-width unsigned integer into a fixed byte array by interpreting the bytes as big-endian.

Source§

impl From<Signed<256, 4>> for B256

Source§

fn from(value: I256) -> Self

Converts a fixed-width unsigned integer into a fixed byte array by interpreting the bytes as big-endian.

Source§

impl From<Signed<256, 4>> for ParseUnits

Source§

fn from(value: I256) -> Self

Converts to this type from the input type.
Source§

impl From<Signed<32, 1>> for B32

Source§

fn from(value: I32) -> Self

Converts a fixed-width unsigned integer into a fixed byte array by interpreting the bytes as big-endian.

Source§

impl From<Signed<512, 8>> for B512

Source§

fn from(value: I512) -> Self

Converts a fixed-width unsigned integer into a fixed byte array by interpreting the bytes as big-endian.

Source§

impl From<Signed<64, 1>> for B64

Source§

fn from(value: I64) -> Self

Converts a fixed-width unsigned integer into a fixed byte array by interpreting the bytes as big-endian.

Source§

impl From<Signed<8, 1>> for B8

Source§

fn from(value: I8) -> Self

Converts a fixed-width unsigned integer into a fixed byte array by interpreting the bytes as big-endian.

Source§

impl<'a, const BITS: usize, const LIMBS: usize> FromSql<'a> for Signed<BITS, LIMBS>

Available on crate feature postgres only.
Source§

fn accepts(ty: &Type) -> bool

Determines if a value of this type can be created from the specified Postgres Type.
Source§

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
Source§

fn from_sql_null(ty: &Type) -> Result<Self, Box<dyn Error + Sync + Send>>

Creates a new value of this type from a NULL SQL value. Read more
Source§

fn from_sql_nullable( ty: &Type, raw: Option<&'a [u8]>, ) -> Result<Self, Box<dyn Error + Sync + Send>>

A convenience function that delegates to from_sql and from_sql_null depending on the value of raw.
Source§

impl<const BITS: usize, const LIMBS: usize> FromStr for Signed<BITS, LIMBS>

Source§

type Err = ParseSignedError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Hash for Signed<BITS, LIMBS>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> LowerHex for Signed<BITS, LIMBS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, const BITS: usize, const LIMBS: usize> Mul<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T, const BITS: usize, const LIMBS: usize> MulAssign<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Neg for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Not for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Octal for Signed<BITS, LIMBS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Ord for Signed<BITS, LIMBS>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> PartialEq for Signed<BITS, LIMBS>

Source§

fn eq(&self, other: &Signed<BITS, LIMBS>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const BITS: usize, const LIMBS: usize> PartialOrd for Signed<BITS, LIMBS>

Source§

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 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T, const BITS: usize, const LIMBS: usize> Product<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

fn product<I: Iterator<Item = T>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<T, const BITS: usize, const LIMBS: usize> Rem<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> Self::Output

Performs the % operation. Read more
Source§

impl<T, const BITS: usize, const LIMBS: usize> RemAssign<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

fn rem_assign(&mut self, rhs: T)

Performs the %= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Serialize for Signed<BITS, LIMBS>

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<i16> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: i16) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<i32> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: i32) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<i64> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: i64) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<i8> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: i8) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<isize> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: isize) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<u16> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u16) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<u32> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u32) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<u64> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u64) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<u8> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u8) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shl<usize> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: usize) -> Self::Output

Performs the << operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<i16> for Signed<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: i16)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<i32> for Signed<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: i32)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<i64> for Signed<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: i64)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<i8> for Signed<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: i8)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<isize> for Signed<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: isize)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<u16> for Signed<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: u16)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<u32> for Signed<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: u32)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<u64> for Signed<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: u64)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<u8> for Signed<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: u8)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShlAssign<usize> for Signed<BITS, LIMBS>

Source§

fn shl_assign(&mut self, rhs: usize)

Performs the <<= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<i16> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: i16) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<i32> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: i32) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<i64> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: i64) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<i8> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: i8) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<isize> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: isize) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<u16> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u16) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<u32> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u32) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<u64> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u64) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<u8> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u8) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Shr<usize> for Signed<BITS, LIMBS>

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: usize) -> Self::Output

Performs the >> operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<i16> for Signed<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: i16)

Performs the >>= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<i32> for Signed<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: i32)

Performs the >>= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<i64> for Signed<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: i64)

Performs the >>= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<i8> for Signed<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: i8)

Performs the >>= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<isize> for Signed<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: isize)

Performs the >>= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<u16> for Signed<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: u16)

Performs the >>= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<u32> for Signed<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: u32)

Performs the >>= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<u64> for Signed<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: u64)

Performs the >>= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<u8> for Signed<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: u8)

Performs the >>= operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> ShrAssign<usize> for Signed<BITS, LIMBS>

Source§

fn shr_assign(&mut self, rhs: usize)

Performs the >>= operation. Read more
Source§

impl<T, const BITS: usize, const LIMBS: usize> Sub<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

type Output = Signed<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, const BITS: usize, const LIMBS: usize> SubAssign<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl<T, const BITS: usize, const LIMBS: usize> Sum<T> for Signed<BITS, LIMBS>
where T: Into<Self>,

Source§

fn sum<I: Iterator<Item = T>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<const BITS: usize, const LIMBS: usize> ToSql for Signed<BITS, LIMBS>

Available on crate feature postgres only.

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.
  • DECIMAL and NUMERIC, 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 as 0x-prefixed big-endian hex strings.
  • JSON, JSONB as a hex string compatible with the Serde serialization.

§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 Signed<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.

Source§

fn to_sql( &self, ty: &Type, out: &mut BytesMut, ) -> Result<IsNull, Box<dyn Error + Sync + Send + 'static>>

Converts the value of self into the binary format of the specified Postgres Type, appending it to out. Read more
Source§

fn accepts(ty: &Type) -> bool

Determines if a value of this type can be converted to the specified Postgres Type.
Source§

fn to_sql_checked( &self, ty: &Type, out: &mut BytesMut, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

An adaptor method used internally by Rust-Postgres. Read more
Source§

fn encode_format(&self, _ty: &Type) -> Format

Specify the encode format
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<&String> for Signed<BITS, LIMBS>

Source§

type Error = ParseSignedError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<&str> for Signed<BITS, LIMBS>

Source§

type Error = ParseSignedError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for Uint<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for i128

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for i16

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<i16, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for i32

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<i32, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for i64

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<i64, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for i8

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<i8, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for isize

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<isize, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for u128

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for u16

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<u16, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for u32

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<u32, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for u64

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<u64, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for u8

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<u8, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Signed<BITS, LIMBS>> for usize

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Signed<BITS, LIMBS>) -> Result<usize, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<String> for Signed<BITS, LIMBS>

Source§

type Error = ParseSignedError

The type returned in the event of a conversion error.
Source§

fn try_from(value: String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<Uint<BITS, LIMBS>> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(from: Uint<BITS, LIMBS>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<i128> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: i128) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<i16> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: i16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<i32> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: i32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<i64> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: i64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<i8> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: i8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<isize> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: isize) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<u128> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: u128) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<u16> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: u16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<u32> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: u32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<u64> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: u64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<u8> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> TryFrom<usize> for Signed<BITS, LIMBS>

Source§

type Error = BigIntConversionError

The type returned in the event of a conversion error.
Source§

fn try_from(value: usize) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const BITS: usize, const LIMBS: usize> UpperHex for Signed<BITS, LIMBS>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Copy for Signed<BITS, LIMBS>

Source§

impl<const BITS: usize, const LIMBS: usize> Eq for Signed<BITS, LIMBS>

Source§

impl<const BITS: usize, const LIMBS: usize> StructuralPartialEq for Signed<BITS, LIMBS>

Auto Trait Implementations§

§

impl<const BITS: usize, const LIMBS: usize> Freeze for Signed<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> RefUnwindSafe for Signed<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> Send for Signed<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> Sync for Signed<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> Unpin for Signed<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> UnwindSafe for Signed<BITS, LIMBS>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> BorrowToSql for T
where T: ToSql,

Source§

fn borrow_to_sql(&self) -> &dyn ToSql

Returns a reference to self as a ToSql trait object.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> FromSqlOwned for T
where T: for<'a> FromSql<'a>,

Source§

impl<T, Rhs, Output> GroupOps<Rhs, Output> for T
where T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>,

Source§

impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T
where T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,