Browse Source

fixing prelude for NAN

pull/5/head
Jason Williams 6 years ago
parent
commit
122770d201
  1. 5
      src/lib/js/value.rs

5
src/lib/js/value.rs

@ -5,6 +5,7 @@ use serde_json::map::Map;
use serde_json::Number as JSONNumber; use serde_json::Number as JSONNumber;
use serde_json::Value as JSONValue; use serde_json::Value as JSONValue;
use std::collections::HashMap; use std::collections::HashMap;
use std::f64::NAN;
use std::fmt::{Display, Formatter, Result as FmtResult}; use std::fmt::{Display, Formatter, Result as FmtResult};
use std::iter::FromIterator; use std::iter::FromIterator;
use std::ops::Deref; use std::ops::Deref;
@ -123,10 +124,10 @@ impl Value {
/// Converts the value into a 64-bit floating point number /// Converts the value into a 64-bit floating point number
pub fn to_num(&self) -> f64 { pub fn to_num(&self) -> f64 {
match *self.ptr { match *self.ptr {
ValueData::Object(_) | ValueData::Undefined | ValueData::Function(_) => std::f64::NAN, ValueData::Object(_) | ValueData::Undefined | ValueData::Function(_) => NAN,
ValueData::String(ref str) => match FromStr::from_str(str) { ValueData::String(ref str) => match FromStr::from_str(str) {
Ok(num) => num, Ok(num) => num,
Err(_) => std::f64::NAN, Err(_) => NAN,
}, },
ValueData::Number(num) => num, ValueData::Number(num) => num,
ValueData::Boolean(true) => 1.0, ValueData::Boolean(true) => 1.0,

Loading…
Cancel
Save