Browse Source

Add From<f32> for JsValue (#1990)

<!---
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
pull/2004/head
Jordan Last 3 years ago
parent
commit
6baf455088
  1. 12
      boa_engine/src/value/conversions.rs

12
boa_engine/src/value/conversions.rs

@ -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 { impl From<u32> for JsValue {
#[inline] #[inline]
fn from(value: u32) -> Self { fn from(value: u32) -> Self {

Loading…
Cancel
Save