Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement i128/u128 to JsBigInt conversions #3129

Merged
merged 6 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 16 additions & 1 deletion boa_engine/src/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,22 @@ impl From<usize> for JsBigInt {
}
}
}

jedel1043 marked this conversation as resolved.
Show resolved Hide resolved
impl From<i128> for JsBigInt {
#[inline]
fn from(value: i128) -> Self {
Self {
inner: Rc::new(RawBigInt::from(value)),
}
}
}
impl From<u128> for JsBigInt {
#[inline]
fn from(value: u128) -> Self {
Self {
inner: Rc::new(RawBigInt::from(value)),
}
}
}
HalidOdat marked this conversation as resolved.
Show resolved Hide resolved
/// The error indicates that the conversion from [`f64`] to [`JsBigInt`] failed.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct TryFromF64Error;
Expand Down
12 changes: 12 additions & 0 deletions boa_engine/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,18 @@ impl From<i64> for Numeric {
Self::BigInt(value.into())
}
}
impl From<i128> for Numeric {
#[inline]
fn from(value: i128) -> Self {
Self::BigInt(value.into())
}
}
impl From<u128> for Numeric {
#[inline]
fn from(value: u128) -> Self {
Self::BigInt(value.into())
}
}

impl From<i32> for Numeric {
#[inline]
Expand Down