diff options
author | Eric Huss <eric@huss.org> | 2018-07-10 16:27:58 -0700 |
---|---|---|
committer | Eric Huss <eric@huss.org> | 2018-07-11 00:50:04 -0700 |
commit | 69b4571c6bafcd7d9f675d3eb49d4c088d372eea (patch) | |
tree | 3a1715fa18ba7640c12fea20ffaa762206c95c62 /src/de.rs | |
parent | 2be7ce9079fa02d9dd42958410ba1c40cef9811c (diff) | |
download | milf-rs-69b4571c6bafcd7d9f675d3eb49d4c088d372eea.tar.gz milf-rs-69b4571c6bafcd7d9f675d3eb49d4c088d372eea.zip |
0.5: Support floats nan, inf, and +/-0.0.
cc #224
Diffstat (limited to 'src/de.rs')
-rw-r--r-- | src/de.rs | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -6,6 +6,7 @@ use std::borrow::Cow; use std::error; +use std::f64; use std::fmt; use std::str; use std::vec; @@ -882,6 +883,14 @@ impl<'a> Deserializer<'a> { } _ => Err(self.error(at, ErrorKind::NumberInvalid)), } + } else if s == "inf" { + Ok(Value { e: E::Float(f64::INFINITY), start: start, end: end }) + } else if s == "-inf" { + Ok(Value { e: E::Float(f64::NEG_INFINITY), start: start, end: end }) + } else if s == "nan" { + Ok(Value { e: E::Float(f64::NAN), start: start, end: end }) + } else if s == "-nan" { + Ok(Value { e: E::Float(-f64::NAN), start: start, end: end }) } else { self.integer(s).map(|f| Value { e: E::Integer(f), start: start, end: end }) } |