We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fc9b234 commit 588cc64Copy full SHA for 588cc64
library/core/src/num/dec2flt/mod.rs
@@ -239,13 +239,15 @@ fn dec2flt<T: RawFloat>(s: &str) -> Result<T, ParseFloatError> {
239
ParseResult::Valid(decimal) => convert(decimal)?,
240
ParseResult::ShortcutToInf => T::INFINITY,
241
ParseResult::ShortcutToZero => T::ZERO,
242
- ParseResult::Invalid => match s {
243
- "inf" => T::INFINITY,
244
- "NaN" => T::NAN,
245
- _ => {
+ 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") {
246
+ T::INFINITY
247
+ } else {
248
return Err(pfe_invalid());
249
}
- },
250
+ }
251
};
252
253
match sign {
0 commit comments