Fix `UDecimal::parse_udecimal` identation.

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
This commit is contained in:
Jean Pierre Dudey 2018-08-21 21:31:02 -04:00
parent 455bc66d3c
commit e48e559740
1 changed files with 22 additions and 22 deletions

View File

@ -287,29 +287,29 @@ impl UDecimal {
// Converts a JSON number to a Decimal previously parsed by strason
#[cfg(feature = "serde-decimal")]
fn parse_udecimal(s: &str) -> Result<UDecimal, ParseDecimalError> {
// We know this will be a well-formed Json number, so we can
// be pretty lax about parsing
let mut past_dec = false;
let mut exponent = 0;
let mut mantissa = 0u64;
// We know this will be a well-formed Json number, so we can
// be pretty lax about parsing
let mut past_dec = false;
let mut exponent = 0;
let mut mantissa = 0u64;
for b in s.as_bytes() {
match *b {
b'0'...b'9' => {
match 10u64.overflowing_mul(mantissa + (b - b'0') as u64) {
(_, true) => return Err(ParseDecimalError::TooBig),
(n, false) => mantissa = n,
}
if past_dec { exponent += 1; }
}
b'.' => { past_dec = true; }
_ => { /* whitespace or something, just ignore it */ }
}
}
Ok(UDecimal {
mantissa: mantissa,
exponent: exponent,
})
for b in s.as_bytes() {
match *b {
b'0'...b'9' => {
match 10u64.overflowing_mul(mantissa + (b - b'0') as u64) {
(_, true) => return Err(ParseDecimalError::TooBig),
(n, false) => mantissa = n,
}
if past_dec { exponent += 1; }
}
b'.' => { past_dec = true; }
_ => { /* whitespace or something, just ignore it */ }
}
}
Ok(UDecimal {
mantissa: mantissa,
exponent: exponent,
})
}
}