Skip to content

Commit

Permalink
chore: code dedup in felt from bigint (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware authored Jan 24, 2025
1 parent 7ef3023 commit fe19c9d
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 @@ -549,15 +549,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 @@ -566,7 +561,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 fe19c9d

Please sign in to comment.