|
|
|
@ -48,7 +48,7 @@ impl Conversion for Bytes
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let (o, u) = match input.char_indices().last().map(|(idx, chr)| (chr.to_lowercase().next().unwrap(), &input[..idx])) {
|
|
|
|
|
Some((chr, _)) if chr.is_numeric() => return Ok((parse!(input: Self::Output), Some(1))),
|
|
|
|
|
Some((chr, _)) if chr.is_numeric() => return Ok((parse!(input: Self::Output), Some(1))),
|
|
|
|
|
|
|
|
|
|
Some((ref chr, non)) if SUFFIX.contains_key(chr) => (parse!(non: IntermediateUnit), *SUFFIX.get(chr).unwrap()),
|
|
|
|
|
|
|
|
|
@ -59,6 +59,11 @@ impl Conversion for Bytes
|
|
|
|
|
if o.is_sign_negative() {
|
|
|
|
|
return Err(ConversionError::new_for(self, "Negative byte offsets not supported"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NOTE: Special-case truncation for if `1.xb` is used.
|
|
|
|
|
if u == 1 {
|
|
|
|
|
return Ok((o.trunc() as Self::Output, Some(1)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok((multiply(o, u), Some(u)))
|
|
|
|
|
}
|
|
|
|
|