From c7e4e0d4333c73deffbdff5c0ebe50e37ab5445c Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Sat, 2 Oct 2021 23:44:52 +0300 Subject: [PATCH] chore: expose I256 functions --- ethers-core/src/types/i256.rs | 10 +++++----- ethers-core/src/types/mod.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ethers-core/src/types/i256.rs b/ethers-core/src/types/i256.rs index f57d84f7..940f82f6 100644 --- a/ethers-core/src/types/i256.rs +++ b/ethers-core/src/types/i256.rs @@ -70,7 +70,7 @@ fn handle_overflow((result, overflow): (T, bool)) -> T { /// Enum to represent the sign of a 256-bit signed integer. #[derive(Clone, Copy, Debug, Eq, PartialEq)] -enum Sign { +pub enum Sign { /// Greater than or equal to zero. Positive, /// Less than zero. @@ -127,7 +127,7 @@ impl I256 { /// Creates an I256 from a sign and an absolute value. Returns the value and /// a bool that is true if the conversion caused an overflow. - fn overflowing_from_sign_and_abs(sign: Sign, abs: U256) -> (Self, bool) { + pub fn overflowing_from_sign_and_abs(sign: Sign, abs: U256) -> (Self, bool) { let value = I256(match sign { Sign::Positive => abs, Sign::Negative => twos_complement(abs), @@ -137,7 +137,7 @@ impl I256 { /// Creates an I256 from an absolute value and a negative flag. Returns /// `None` if it would overflow an `I256`. - fn checked_from_sign_and_abs(sign: Sign, abs: U256) -> Option { + pub fn checked_from_sign_and_abs(sign: Sign, abs: U256) -> Option { let (result, overflow) = I256::overflowing_from_sign_and_abs(sign, abs); if overflow { None @@ -147,7 +147,7 @@ impl I256 { } /// Splits a I256 into its absolute value and negative flag. - fn into_sign_and_abs(self) -> (Sign, U256) { + pub fn into_sign_and_abs(self) -> (Sign, U256) { let sign = self.sign(); let abs = match sign { Sign::Positive => self.0, @@ -157,7 +157,7 @@ impl I256 { } /// Returns the sign of self. - fn sign(self) -> Sign { + pub fn sign(self) -> Sign { let most_significant_word = (self.0).0[3]; match most_significant_word & (1 << 63) { 0 => Sign::Positive, diff --git a/ethers-core/src/types/mod.rs b/ethers-core/src/types/mod.rs index beedbe77..16aa5223 100644 --- a/ethers-core/src/types/mod.rs +++ b/ethers-core/src/types/mod.rs @@ -22,7 +22,7 @@ mod path_or_string; pub use path_or_string::PathOrString; mod i256; -pub use i256::I256; +pub use i256::{Sign, I256}; mod bytes; pub use self::bytes::Bytes;