Skip to content

Commit

Permalink
feat: impl ToBigInt and ToBigUInt (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdelabro authored Jun 25, 2024
1 parent d3d77a5 commit 573c589
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crates/starknet-types-core/src/felt/num_traits_impl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
use super::Felt;
use num_bigint::{ToBigInt, ToBigUint};
use num_traits::{FromPrimitive, Inv, One, Pow, ToPrimitive, Zero};

impl ToBigInt for Felt {
/// Converts the value of `self` to a [`BigInt`].
///
/// Safe to unwrap, will always return `Some`.
fn to_bigint(&self) -> Option<num_bigint::BigInt> {
Some(self.to_bigint())
}
}

impl ToBigUint for Felt {
/// Converts the value of `self` to a [`BigUint`].
///
/// Safe to unwrap, will always return `Some`.
fn to_biguint(&self) -> Option<num_bigint::BigUint> {
Some(self.to_biguint())
}
}

impl FromPrimitive for Felt {
fn from_i64(value: i64) -> Option<Self> {
Some(value.into())
Expand Down

0 comments on commit 573c589

Please sign in to comment.