aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2023-01-20 17:52:17 -0330
committerSam Anthony <sam@samanthony.xyz>2023-01-20 17:52:17 -0330
commit308f00b560785580981b2ebde5d7ffc9b7188ba8 (patch)
tree2e3699b7456f0b1c5752171bb4653ea7b6152a57
parent5405811eaa2af3e84cc3423010488d8429657bb8 (diff)
downloadvolute-308f00b560785580981b2ebde5d7ffc9b7188ba8.zip
clean up UI.convert_displacement()
-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;
}