diff options
| -rw-r--r-- | src/main.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs index aabef0a..cc06d95 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,17 +41,12 @@ impl App { impl UI { fn convert_displacement(&mut self, unit: volume::Unit) { if self.displacement.len() > 0 { - self.displacement = format!( - "{}", - round( - volume::convert( - self.displacement.parse::<f64>().unwrap(), - self.displacement_unit, - unit, - ), - DECIMAL_DIGITS, - ), + let old = self.displacement.parse::<f64>().unwrap(); + let new = round( + volume::convert(old, self.displacement_unit, unit), + DECIMAL_DIGITS, ); + self.displacement = format!("{}", new); } self.displacement_unit = unit; } |