Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat: make I256::from_raw() as const #305

Merged
merged 2 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ethers-core/src/types/i256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl I256 {
/// Coerces an unsigned integer into a signed one. If the unsigned integer
/// is greater than the greater than or equal to `1 << 255`, then the result
/// will overflow into a negative value.
pub fn from_raw(raw: U256) -> Self {
pub const fn from_raw(raw: U256) -> Self {
I256(raw)
}

Expand Down Expand Up @@ -1263,6 +1263,9 @@ mod tests {

#[test]
fn identities() {
const ONE: I256 = I256::from_raw(U256([1, 0, 0, 0]));
assert_eq!(ONE, I256::one());

assert_eq!(I256::zero().to_string(), "0");
assert_eq!(I256::one().to_string(), "1");
assert_eq!(I256::minus_one().to_string(), "-1");
Expand Down
2 changes: 1 addition & 1 deletion ethers/examples/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ethers_signers::{LocalWallet, Signer};
async fn main() -> Result<()> {
// Generate a random wallet
let wallet = LocalWallet::new(&mut thread_rng());

// Declare the message you want to sign.
let message = "Some data";

Expand Down