aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs15
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;
}