diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2023-01-20 17:52:17 -0330 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2023-01-20 17:52:17 -0330 |
| commit | 308f00b560785580981b2ebde5d7ffc9b7188ba8 (patch) | |
| tree | 2e3699b7456f0b1c5752171bb4653ea7b6152a57 /src/main.rs | |
| parent | 5405811eaa2af3e84cc3423010488d8429657bb8 (diff) | |
| download | volute-308f00b560785580981b2ebde5d7ffc9b7188ba8.zip | |
clean up UI.convert_displacement()
Diffstat (limited to 'src/main.rs')
| -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; } |