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

Commit 01cc807

Browse files
authored
feat: make I256::from_raw() as const (#305)
* feat: make I256::from_raw() as const * misc: fix 'cargo fmt' issue
1 parent ed46935 commit 01cc807

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: ethers-core/src/types/i256.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl I256 {
168168
/// Coerces an unsigned integer into a signed one. If the unsigned integer
169169
/// is greater than the greater than or equal to `1 << 255`, then the result
170170
/// will overflow into a negative value.
171-
pub fn from_raw(raw: U256) -> Self {
171+
pub const fn from_raw(raw: U256) -> Self {
172172
I256(raw)
173173
}
174174

@@ -1263,6 +1263,9 @@ mod tests {
12631263

12641264
#[test]
12651265
fn identities() {
1266+
const ONE: I256 = I256::from_raw(U256([1, 0, 0, 0]));
1267+
assert_eq!(ONE, I256::one());
1268+
12661269
assert_eq!(I256::zero().to_string(), "0");
12671270
assert_eq!(I256::one().to_string(), "1");
12681271
assert_eq!(I256::minus_one().to_string(), "-1");

Diff for: ethers/examples/sign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use ethers_signers::{LocalWallet, Signer};
1010
async fn main() -> Result<()> {
1111
// Generate a random wallet
1212
let wallet = LocalWallet::new(&mut thread_rng());
13-
13+
1414
// Declare the message you want to sign.
1515
let message = "Some data";
1616

0 commit comments

Comments
 (0)