From a2053c850515a0d9f45cd0a3cec9acc555117e87 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Thu, 30 Mar 2017 12:40:27 +0100 Subject: Simplify if-statements --- src/de.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/de.rs') diff --git a/src/de.rs b/src/de.rs index 0888186..0022791 100644 --- a/src/de.rs +++ b/src/de.rs @@ -687,7 +687,7 @@ impl<'a> Deserializer<'a> { } fn number_or_date(&mut self, s: &'a str) -> Result, Error> { - if s.contains("T") || (s.len() > 1 && s[1..].contains("-")) && + if s.contains('T') || (s.len() > 1 && s[1..].contains('-')) && !s.contains("e-") { self.datetime(s, false).map(Value::Datetime) } else if self.eat(Token::Colon)? { @@ -698,7 +698,7 @@ impl<'a> Deserializer<'a> { } fn number(&mut self, s: &'a str) -> Result, Error> { - if s.contains("e") || s.contains("E") { + if s.contains('e') || s.contains('E') { self.float(s, None).map(Value::Float) } else if self.eat(Token::Period)? { let at = self.tokens.current(); @@ -727,7 +727,7 @@ impl<'a> Deserializer<'a> { if suffix != "" { return Err(self.error(start, ErrorKind::NumberInvalid)) } - prefix.replace("_", "").trim_left_matches("+").parse().map_err(|_e| { + prefix.replace("_", "").trim_left_matches('+').parse().map_err(|_e| { self.error(start, ErrorKind::NumberInvalid) }) } @@ -789,7 +789,7 @@ impl<'a> Deserializer<'a> { } let mut exponent = None; - if suffix.starts_with("e") || suffix.starts_with("E") { + if suffix.starts_with('e') || suffix.starts_with('E') { let (a, b) = if suffix.len() == 1 { self.eat(Token::Plus)?; match self.next()? { @@ -807,7 +807,7 @@ impl<'a> Deserializer<'a> { exponent = Some(a); } - let mut number = integral.trim_left_matches("+") + let mut number = integral.trim_left_matches('+') .chars() .filter(|c| *c != '_') .collect::(); -- cgit v1.2.3