pub trait AsU256 {
    // Required method
    fn as_u256(self) -> U256;
}
Expand description

This trait defines as conversions (casting) from primitive types to U256.

§Examples

Note that in Rust casting from a negative signed integer sign to a larger unsigned interger sign extends. Additionally casting a floating point value to an integer is a saturating operation, with NaN converting to 0. So:

assert_eq!((-1i32).as_u256(), U256::MAX);
assert_eq!(u32::MAX.as_u256(), 0xffffffff);

assert_eq!(f64::NEG_INFINITY.as_u256(), 0);
assert_eq!((-1.0f64).as_u256(), 0);
assert_eq!(f64::INFINITY.as_u256(), U256::MAX);
assert_eq!(2.0f64.powi(257).as_u256(), U256::MAX);
assert_eq!(f64::NAN.as_u256(), 0);

Required Methods§

fn as_u256(self) -> U256

Perform an as conversion to a U256.

Implementations on Foreign Types§

§

impl AsU256 for bool

§

fn as_u256(self) -> U256

§

impl AsU256 for f32

§

fn as_u256(self) -> U256

§

impl AsU256 for f64

§

fn as_u256(self) -> U256

§

impl AsU256 for i8

§

fn as_u256(self) -> U256

§

impl AsU256 for i16

§

fn as_u256(self) -> U256

§

impl AsU256 for i32

§

fn as_u256(self) -> U256

§

impl AsU256 for i64

§

fn as_u256(self) -> U256

§

impl AsU256 for i128

§

fn as_u256(self) -> U256

§

impl AsU256 for isize

§

fn as_u256(self) -> U256

§

impl AsU256 for u8

§

fn as_u256(self) -> U256

§

impl AsU256 for u16

§

fn as_u256(self) -> U256

§

impl AsU256 for u32

§

fn as_u256(self) -> U256

§

impl AsU256 for u64

§

fn as_u256(self) -> U256

§

impl AsU256 for u128

§

fn as_u256(self) -> U256

§

impl AsU256 for usize

§

fn as_u256(self) -> U256

Implementors§

§

impl AsU256 for I256

§

impl AsU256 for U256