Add ability to read NaN/Infinity

This commit is contained in:
Jubilee Young 2020-10-31 12:30:22 -07:00
parent fc9b234928
commit 588cc644ad

View File

@ -239,13 +239,15 @@ fn dec2flt<T: RawFloat>(s: &str) -> Result<T, ParseFloatError> {
ParseResult::Valid(decimal) => convert(decimal)?,
ParseResult::ShortcutToInf => T::INFINITY,
ParseResult::ShortcutToZero => T::ZERO,
ParseResult::Invalid => match s {
"inf" => T::INFINITY,
"NaN" => T::NAN,
_ => {
ParseResult::Invalid => {
if s.eq_ignore_ascii_case("nan") {
T::NAN
} else if s.eq_ignore_ascii_case("inf") || s.eq_ignore_ascii_case("infinity") {
T::INFINITY
} else {
return Err(pfe_invalid());
}
},
}
};
match sign {