Struct apint::UInt[][src]

pub struct UInt { /* fields omitted */ }

Unsigned machine integer with arbitrary bitwidths and modulo arithmetics.

Thin convenience wrapper around ApInt for static unsigned interpretation of the value.

This very cheaply transformes to and from ApInt and Int instances and together with Int offers a more elegant and higher-level abstraction interface to the lower-level ApInt.

Methods

impl UInt
[src]

Transforms this UInt into an equivalent ApInt instance.

Transforms this UInt into an equivalent Int instance.

impl UInt
[src]

Creates a new UInt from the given Bit value with a bit width of 1.

This function is generic over types that are convertible to Bit such as bool.

Creates a new UInt from a given u8 value with a bit-width of 8.

Creates a new UInt from a given u16 value with a bit-width of 16.

Creates a new UInt from a given u32 value with a bit-width of 32.

Creates a new UInt from a given u64 value with a bit-width of 64.

Creates a new UInt from a given u64 value with a bit-width of 64.

Creates a new UInt with the given bit width that represents zero.

Creates a new UInt with the given bit width that represents one.

Creates a new UInt with the given bit width that has all bits unset.

Note: This is equal to calling UInt::zero with the given width.

Creates a new UInt with the given bit width that has all bits set.

Note

  • This is equal to minus one on any twos-complement machine.

Returns the smallest UInt that can be represented by the given BitWidth.

Returns the largest UInt that can be represented by the given BitWidth.

impl UInt
[src]

Returns true if this UInt represents the value zero (0).

Note

  • Zero (0) is also called the additive neutral element.
  • This operation is more efficient than comparing two instances of UInt for the same reason.

Returns true if this UInt represents the value one (1).

Note

  • One (1) is also called the multiplicative neutral element.
  • This operation is more efficient than comparing two instances of UInt for the same reason.

Returns true if this UInt represents an even number.

Returns true if this UInt represents an odd number.

impl UInt
[src]

Less-than (lt) comparison between self and rhs.

Note

  • Returns Ok(true) if self < rhs.
  • Interprets both UInt instances as unsigned values.

Errors

  • If self and rhs have unmatching bit widths.

Less-equals (le) comparison between self and rhs.

Note

  • Returns Ok(true) if self <= rhs.
  • Interprets both UInt instances as unsigned values.

Errors

  • If self and rhs have unmatching bit widths.

Greater-than (gt) comparison between self and rhs.

Note

  • Returns Ok(true) if self > rhs.
  • Interprets both UInt instances as unsigned values.

Errors

  • If self and rhs have unmatching bit widths.

Greater-equals (ge) comparison between self and rhs.

Note

  • Returns Ok(true) if self >= rhs.
  • Interprets both UInt instances as unsigned values.

Errors

  • If self and rhs have unmatching bit widths.

impl UInt
[src]

Resizes this UInt to a bool primitive type.

Bits in this UInt that are not within the bounds of the bool are being ignored.

Note

  • Basically this returns true if the least significant bit of this UInt is 1 and false otherwise.

Resizes this UInt to a u8 primitive type.

Note

  • All bits but the least significant 8 bits are being ignored by this operation to construct the result.

Resizes this UInt to a u16 primitive type.

Note

  • All bits but the least significant 16 bits are being ignored by this operation to construct the result.

Resizes this UInt to a u32 primitive type.

Note

  • All bits but the least significant 32 bits are being ignored by this operation to construct the result.

Resizes this UInt to a u64 primitive type.

Note

  • All bits but the least significant 64 bits are being ignored by this operation to construct the result.

Resizes this UInt to a u128 primitive type.

Note

  • All bits but the least significant 128 bits are being ignored by this operation to construct the result.

impl UInt
[src]

Tries to represent the value of this UInt as a bool.

Note

This returns true if the value represented by this UInt is 1, returns false if the value represented by this UInt is 0 and returns an error otherwise.

Errors

  • If the value represented by this UInt can not be represented by a bool.

Tries to represent the value of this UInt as a u8.

Note

  • This conversion is possible as long as the value represented by this UInt does not exceed the maximum value of u8.

Errors

  • If the value represented by this UInt can not be represented by a u8.

Tries to represent the value of this UInt as a u16.

Note

  • This conversion is possible as long as the value represented by this UInt does not exceed the maximum value of u16.

Errors

  • If the value represented by this UInt can not be represented by a u16.

Tries to represent the value of this UInt as a u32.

Note

  • This conversion is possible as long as the value represented by this UInt does not exceed the maximum value of u32.

Errors

  • If the value represented by this UInt can not be represented by a u32.

Tries to represent the value of this UInt as a u64.

Note

  • This conversion is possible as long as the value represented by this UInt does not exceed the maximum value of u64.

Errors

  • If the value represented by this UInt can not be represented by a u64.

Tries to represent the value of this UInt as a u128.

Note

  • This conversion is possible as long as the value represented by this UInt does not exceed the maximum value of u128.

Complexity

  • 𝒪(n) where n is the number of digits of this UInt.

Errors

  • If the value represented by this UInt can not be represented by a u128.

impl UInt
[src]

Shift this UInt left by the given shift_amount bits.

This operation is inplace and will not allocate memory.

Errors

  • If the given shift_amount is invalid for the bit width of this UInt.

Shift this UInt left by the given shift_amount bits and returns the result.

This operation is inplace and will not allocate memory.

Errors

  • If the given shift_amount is invalid for the bit width of this UInt.

Right-shifts this UInt by the given shift_amount bits.

This operation is inplace and will not allocate memory.

Errors

  • If the given shift_amount is invalid for the bit width of this UInt.

Right-shifts this UInt by the given shift_amount bits and returns the result.

This operation is inplace and will not allocate memory.

Errors

  • If the given shift_amount is invalid for the bit width of this UInt.

impl UInt
[src]

Creates a new UInt with the given BitWidth and random Digits.

Creates a new UInt with the given BitWidth and random Digits using the given random number generator.

Note: This is useful for cryptographic or testing purposes.

Randomizes the digits of this UInt inplace.

This won't change its BitWidth.

Randomizes the digits of this UInt inplace using the given random number generator.

This won't change its BitWidth.

impl UInt
[src]

Assigns rhs to this UInt.

This mutates digits and may affect the bitwidth of self which might result in an expensive operations.

After this operation rhs and self are equal to each other.

Strictly assigns rhs to this UInt.

After this operation rhs and self are equal to each other.

Note: Strict assigns protect against mutating the bit width of self and thus return an error instead of executing a probably expensive assign operation.

Errors

  • If rhs and self have unmatching bit widths.

impl UInt
[src]

Tries to truncate this UInt inplace to the given target_width and returns the result.

Note

  • This is useful for method chaining.
  • For more details look into truncate.

Errors

  • If the target_width is greater than the current width.

Tries to truncate this UInt inplace to the given target_width.

Note

  • This is a no-op if self.width() and target_width are equal.
  • This operation is inplace as long as self.width() and target_width require the same amount of digits for their representation.

Errors

  • If the target_width is greater than the current width.

Tries to zero-extend this UInt inplace to the given target_width and returns the result.

Note

  • This is useful for method chaining.
  • For more details look into extend.

Errors

  • If the target_width is less than the current width.

Tries to extend this UInt inplace to the given target_width.

Note

  • This is a no-op if self.width() and target_width are equal.
  • This operation is inplace as long as self.width() and target_width require the same amount of digits for their representation.

Errors

  • If the target_width is less than the current width.

Resizes this UInt to the given target_width and returns the result.

Note

  • This is useful for method chaining.
  • For more details look into resize.

Resizes the given UInt inplace.

Note

This operation will forward to

  • truncate if target_width is less than or equal to the width of the given UInt
  • extend otherwise

impl UInt
[src]

Flips all bits of self and returns the result.

Flip all bits of this UInt inplace.

Tries to bit-and assign this UInt inplace to rhs and returns the result.

Note: This forwards to checked_bitand.

Errors

If self and rhs have unmatching bit widths.

Bit-and assigns all bits of this UInt with the bits of rhs.

Note: This operation is inplace of self and won't allocate memory.

Errors

If self and rhs have unmatching bit widths.

Tries to bit-and assign this UInt inplace to rhs and returns the result.

Note: This forwards to checked_bitor.

Errors

If self and rhs have unmatching bit widths.

Bit-or assigns all bits of this UInt with the bits of rhs.

Note: This operation is inplace of self and won't allocate memory.

Errors

If self and rhs have unmatching bit widths.

Tries to bit-xor assign this UInt inplace to rhs and returns the result.

Note: This forwards to checked_bitxor.

Errors

If self and rhs have unmatching bit widths.

Bit-xor assigns all bits of this UInt with the bits of rhs.

Note: This operation is inplace of self and won't allocate memory.

Errors

If self and rhs have unmatching bit widths.

impl UInt
[src]

Returns the bit at the given bit position pos.

This returns

  • Bit::Set if the bit at pos is 1
  • Bit::Unset otherwise

Errors

  • If pos is not a valid bit position for the width of this UInt.

Sets the bit at the given bit position pos to one (1).

Errors

  • If pos is not a valid bit position for the width of this UInt.

Sets the bit at the given bit position pos to zero (0).

Errors

  • If pos is not a valid bit position for the width of this UInt.

Flips the bit at the given bit position pos.

Note

  • If the bit at the given position was 0 it will be 1 after this operation and vice versa.

Errors

  • If pos is not a valid bit position for the width of this UInt.

Sets all bits of this UInt to one (1).

Returns true if all bits in this UInt are set.

Sets all bits of this UInt to zero (0).

Returns true if all bits in this UInt are unset.

Flips all bits of this UInt.

impl UInt
[src]

Returns the number of ones in the binary representation of this UInt.

Returns the number of zeros in the binary representation of this UInt.

Returns the number of leading zeros in the binary representation of this UInt.

Returns the number of trailing zeros in the binary representation of this UInt.

impl UInt
[src]

Adds rhs to self and returns the result.

Note: This will not allocate memory.

Errors

  • If self and rhs have unmatching bit widths.

Add-assigns rhs to self inplace.

Note: This will not allocate memory.

Errors

  • If self and rhs have unmatching bit widths.

Subtracts rhs from self and returns the result.

Note

In the low-level bit-wise representation there is no difference between signed and unsigned subtraction of fixed bit-width integers. (Cite: LLVM)

Errors

  • If self and rhs have unmatching bit widths.

Subtract-assigns rhs from self inplace.

Note

In the low-level bit-wise representation there is no difference between signed and unsigned subtraction of fixed bit-width integers. (Cite: LLVM)

Errors

  • If self and rhs have unmatching bit widths.

Subtracts rhs from self and returns the result.

Note

In the low-level bit-wise representation there is no difference between signed and unsigned multiplication of fixed bit-width integers. (Cite: LLVM)

Errors

  • If self and rhs have unmatching bit widths.

Multiply-assigns rhs to self inplace.

Note

In the low-level bit-wise representation there is no difference between signed and unsigned multiplication of fixed bit-width integers. (Cite: LLVM)

Errors

  • If self and rhs have unmatching bit widths.

Divides self by rhs and returns the result.

Note

  • This operation will not allocate memory and computes inplace of self.
  • In the low-level machine abstraction signed division and unsigned division are two different operations.

Errors

  • If self and rhs have unmatching bit widths.

Assignes self to the division of self by rhs.

Note

  • This operation will not allocate memory and computes inplace of self.
  • In the low-level machine abstraction signed division and unsigned division are two different operations.

Errors

  • If self and rhs have unmatching bit widths.

Calculates the unsigned remainder of self by rhs and returns the result.

Note

  • This operation will not allocate memory and computes inplace of self.
  • In the low-level machine abstraction signed division and unsigned division are two different operations.

Errors

  • If self and rhs have unmatching bit widths.

Assignes self to the unsigned remainder of self by rhs.

Note

  • This operation will not allocate memory and computes inplace of self.
  • In the low-level machine abstraction signed division and unsigned division are two different operations.

Errors

  • If self and rhs have unmatching bit widths.

Trait Implementations

impl Debug for UInt
[src]

Formats the value using the given formatter. Read more

impl Clone for UInt
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for UInt
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for UInt
[src]

impl Hash for UInt
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl From<ApInt> for UInt
[src]

Performs the conversion.

impl<B> From<B> for UInt where
    B: Into<Bit>, 
[src]

Performs the conversion.

impl From<u8> for UInt
[src]

Performs the conversion.

impl From<u16> for UInt
[src]

Performs the conversion.

impl From<u32> for UInt
[src]

Performs the conversion.

impl From<u64> for UInt
[src]

Performs the conversion.

impl From<u128> for UInt
[src]

Performs the conversion.

impl From<[u64; 2]> for UInt
[src]

Performs the conversion.

impl From<[u64; 3]> for UInt
[src]

Performs the conversion.

impl From<[u64; 4]> for UInt
[src]

Performs the conversion.

impl From<[u64; 5]> for UInt
[src]

Performs the conversion.

impl From<[u64; 6]> for UInt
[src]

Performs the conversion.

impl From<[u64; 7]> for UInt
[src]

Performs the conversion.

impl From<[u64; 8]> for UInt
[src]

Performs the conversion.

impl From<[u64; 16]> for UInt
[src]

Performs the conversion.

impl From<[u64; 32]> for UInt
[src]

Performs the conversion.

impl PartialOrd for UInt
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<S> Shl<S> for UInt where
    S: Into<ShiftAmount>, 
[src]

The resulting type after applying the << operator.

Performs the << operation.

impl<S> Shr<S> for UInt where
    S: Into<ShiftAmount>, 
[src]

The resulting type after applying the >> operator.

Performs the >> operation.

impl<S> ShlAssign<S> for UInt where
    S: Into<ShiftAmount>, 
[src]

Performs the <<= operation.

impl<S> ShrAssign<S> for UInt where
    S: Into<ShiftAmount>, 
[src]

Performs the >>= operation.

impl Not for UInt
[src]

The resulting type after applying the ! operator.

Performs the unary ! operation.

impl<'a> BitAnd<&'a UInt> for UInt
[src]

The resulting type after applying the & operator.

Performs the & operation.

impl<'a, 'b> BitAnd<&'a UInt> for &'b UInt
[src]

The resulting type after applying the & operator.

Performs the & operation.

impl<'a, 'b> BitAnd<&'a UInt> for &'b mut UInt
[src]

The resulting type after applying the & operator.

Performs the & operation.

impl<'a> BitOr<&'a UInt> for UInt
[src]

The resulting type after applying the | operator.

Performs the | operation.

impl<'a, 'b> BitOr<&'a UInt> for &'b UInt
[src]

The resulting type after applying the | operator.

Performs the | operation.

impl<'a, 'b> BitOr<&'a UInt> for &'b mut UInt
[src]

The resulting type after applying the | operator.

Performs the | operation.

impl<'a> BitXor<&'a UInt> for UInt
[src]

The resulting type after applying the ^ operator.

Performs the ^ operation.

impl<'a, 'b> BitXor<&'a UInt> for &'b UInt
[src]

The resulting type after applying the ^ operator.

Performs the ^ operation.

impl<'a, 'b> BitXor<&'a UInt> for &'b mut UInt
[src]

The resulting type after applying the ^ operator.

Performs the ^ operation.

impl<'a> BitAndAssign<&'a UInt> for UInt
[src]

Performs the &= operation.

impl<'a> BitOrAssign<&'a UInt> for UInt
[src]

Performs the |= operation.

impl<'a> BitXorAssign<&'a UInt> for UInt
[src]

Performs the ^= operation.

impl<'a> Add<&'a UInt> for UInt
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl<'a, 'b> Add<&'a UInt> for &'b UInt
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl<'a> AddAssign<&'a UInt> for UInt
[src]

Performs the += operation.

impl<'a> Sub<&'a UInt> for UInt
[src]

The resulting type after applying the - operator.

Performs the - operation.

impl<'a, 'b> Sub<&'a UInt> for &'b UInt
[src]

The resulting type after applying the - operator.

Performs the - operation.

impl<'a> SubAssign<&'a UInt> for UInt
[src]

Performs the -= operation.

impl<'a> Mul<&'a UInt> for UInt
[src]

The resulting type after applying the * operator.

Performs the * operation.

impl<'a, 'b> Mul<&'a UInt> for &'b UInt
[src]

The resulting type after applying the * operator.

Performs the * operation.

impl<'a> MulAssign<&'a UInt> for UInt
[src]

Performs the *= operation.

impl<'a> Div<&'a UInt> for UInt
[src]

The resulting type after applying the / operator.

Performs the / operation.

impl<'a, 'b> Div<&'a UInt> for &'b UInt
[src]

The resulting type after applying the / operator.

Performs the / operation.

impl<'a> DivAssign<&'a UInt> for UInt
[src]

Performs the /= operation.

impl<'a> Rem<&'a UInt> for UInt
[src]

The resulting type after applying the % operator.

Performs the % operation.

impl<'a, 'b> Rem<&'a UInt> for &'b UInt
[src]

The resulting type after applying the % operator.

Performs the % operation.

impl<'a> RemAssign<&'a UInt> for UInt
[src]

Performs the %= operation.

impl Binary for UInt
[src]

Formats the value using the given formatter.

impl Octal for UInt
[src]

Formats the value using the given formatter.

impl LowerHex for UInt
[src]

Formats the value using the given formatter.

impl UpperHex for UInt
[src]

Formats the value using the given formatter.

Auto Trait Implementations

impl Send for UInt

impl Sync for UInt