pub use ::primitive_types::{H160, H256};
#[doc(hidden)]
pub trait U256Ext: Sealed + Sized + Eq + PartialEq + Ord + PartialOrd + Clone + Copy {
const ZERO: Self;
const ONE: Self;
const VALUE_32: Self;
const VALUE_64: Self;
const VALUE_256: Self;
const USIZE_MAX: Self;
const U64_MAX: Self;
const U32_MAX: Self;
const SIGN_BIT_MASK: Self;
fn add_mod(self, op2: Self, op3: Self) -> Self;
fn mul_mod(self, op2: Self, op3: Self) -> Self;
fn to_usize(&self) -> usize {
assert!(*self <= Self::USIZE_MAX);
self.low_usize()
}
fn to_u64(&self) -> u64 {
assert!(*self <= Self::U64_MAX);
self.low_u64()
}
fn to_u32(&self) -> u32 {
assert!(*self <= Self::U32_MAX);
self.low_u32()
}
fn low_u64(&self) -> u64;
fn low_u32(&self) -> u32;
fn low_usize(&self) -> usize;
fn from_u32(v: u32) -> Self;
fn from_u64(v: u64) -> Self;
fn from_usize(v: usize) -> Self;
fn to_h256(self) -> H256;
fn from_h256(v: H256) -> Self;
fn to_h160(self) -> H160 {
self.to_h256().into()
}
fn from_h160(v: H160) -> Self {
Self::from_h256(v.into())
}
fn is_zero(&self) -> bool {
*self == Self::ZERO
}
fn bit(&self, index: usize) -> bool;
fn bits(&self) -> usize;
fn log2floor(&self) -> u64;
fn append_to_rlp_stream(&self, rlp: &mut rlp::RlpStream);
}
#[cfg(not(feature = "ruint"))]
mod primitive_types;
#[cfg(not(feature = "ruint"))]
use self::primitive_types::Sealed;
#[cfg(not(feature = "ruint"))]
pub use self::primitive_types::U256;
#[cfg(feature = "ruint")]
mod ruint;
#[cfg(feature = "ruint")]
use self::ruint::Sealed;
#[cfg(feature = "ruint")]
pub use self::ruint::U256;
#[cfg(test)]
mod tests {
#[allow(unused_imports)]
use super::{U256, U256Ext};
#[test]
fn shl_overflowing() {
assert_eq!(U256::ONE << 257, U256::ZERO);
}
}