Skip to content

Commit

Permalink
Add From<f32> for JsValue (#1990)
Browse files Browse the repository at this point in the history
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel neccesary.
--->

This Pull Request fixes/closes #1989.

It changes the following:

- Implements From<f32> for JsValue
  • Loading branch information
lastmjs committed Apr 2, 2022
1 parent 998a7b1 commit 6baf455
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions boa_engine/src/value/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ impl From<f64> for JsValue {
}
}

impl From<f32> for JsValue {
#[allow(clippy::float_cmp)]
#[inline]
fn from(value: f32) -> Self {
// if value as i32 as f32 == value {
// Self::Integer(value as i32)
// } else {
Self::Rational(value.into())
// }
}
}

impl From<u32> for JsValue {
#[inline]
fn from(value: u32) -> Self {
Expand Down

0 comments on commit 6baf455

Please sign in to comment.