pub struct U256(pub Uint<4>);

Tuple Fields

0: Uint<4>

Implementations

Uses radix 16 if src has a leading 0x, otherwise uses radix 10

The uint implementation of FromStr is unsuitable because it is hexadecimal only (intentional by their developers because they did not make the mistake of using decimal in message passing implementations and do not have wasteful “0x” prefixes), this function will switch between hexadecimal and decimal depending on if there is a “0x” prefix.

Same as from_dec_or_hex_str but may not allow for ‘_’ or more than 78 bytes

This function is intended for formatting intermediates that use stack buffers.

Assigns a hex representation of self to buf[index..] (cast as a byte array with bytemuck) and returns the index. No prefix or minimum “0” are set (returns 64 if self.is_zero()). Also, bytes in buf[..index] may be set arbitrarily. Only b’0’-b’9’ and b’a’-b’f’ can be output to buf[index..].

Returns a hexadecimal string representation of self, including a “0x” prefix. If self.is_zero(), this returns “0x0”

Prefixes not included. Note: if self.is_zero, the Vec is empty.

Returns None if the radix is not valid

Returns 10^exp, or None if overflow occurs

Significant bits

This gives a straight byte slice view into self, be aware that it changes on big endian systems

Note: this is an identity: U256::from_bytes(&x0.to_u8_array()[..(32 - (x0.lz() / 8))]).unwrap()

Errors

If the number of bytes is greater than the number of bytes in Self

Note: this is an identity: U256::from_bytes_be(&x0.to_u8_array_be()[(x0.lz() / 8)..]).unwrap()

Errors

If the number of bytes is greater than the number of bytes in Self

Shift left by 1. Returns None if numerical overflow results

Shift right by 1

Randomly-assigns self using a rand_core::RngCore random number generator

// Example using the `rand_xoshiro` crate.
use rand_xoshiro::{rand_core::SeedableRng, Xoshiro128StarStar};
use u64_array_bigints::U256;

let mut rng = Xoshiro128StarStar::seed_from_u64(0);

assert_eq!(
    U256::rand_using(&mut rng),
    U256::from_u64_array([
        0x9a089d75dec9045d,
        0xc3e16405ab77d362,
        0x60dea0565c95a8da,
        0xa4290614c25a5140,
    ])
);

These are forwarded from Uint<4>

Trait Implementations

The resulting type after applying the & operator.

Performs the & operation. Read more

Performs the &= operation. Read more

The resulting type after applying the | operator.

Performs the | operation. Read more

Performs the |= operation. Read more

The resulting type after applying the ^ operator.

Performs the ^ operation. Read more

Performs the ^= operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Uses from_dec_or_hex_str_restricted.

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

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

Formats the value using the given formatter.

The resulting type after applying the ! operator.

Performs the unary ! operation. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

Includes a “0x” prefix.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.