Skip to content

Commit

Permalink
chore: code dedup in felt from bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Sep 22, 2024
1 parent b13ccec commit 21ec015
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions crates/starknet-types-core/src/felt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,15 +574,10 @@ impl From<&BigInt> for Felt {

impl From<BigInt> for Felt {
fn from(bigint: BigInt) -> Felt {
let (sign, bytes) = bigint.to_bytes_le();
let felt = Felt::from_bytes_le_slice(&bytes);
if sign == Sign::Minus {
felt.neg()
} else {
felt
}
Self::from(&bigint)
}
}

impl From<&BigUint> for Felt {
fn from(biguint: &BigUint) -> Felt {
Felt::from_bytes_le_slice(&biguint.to_bytes_le())
Expand All @@ -591,7 +586,7 @@ impl From<&BigUint> for Felt {

impl From<BigUint> for Felt {
fn from(biguint: BigUint) -> Felt {
Felt::from_bytes_le_slice(&biguint.to_bytes_le())
Self::from(&biguint)
}
}

Expand Down

0 comments on commit 21ec015

Please sign in to comment.