Adding SpeedUnit and TempUnit

This commit is contained in:
2023-06-08 23:10:21 +02:00
parent 09df3cc6ed
commit cd04da0d91
9 changed files with 184 additions and 46 deletions
+30
View File
@@ -0,0 +1,30 @@
use structopt::clap::arg_enum;
arg_enum! {
#[derive(Debug)]
pub enum SpeedUnit {
Kmh,
Ms,
Mph,
Knots
}
}
pub fn speed_to_unit_string(speed_unit: &SpeedUnit) -> String {
match speed_unit {
SpeedUnit::Kmh => "km/h".to_string(),
SpeedUnit::Ms => "m/s".to_string(),
SpeedUnit::Mph => "mp/h".to_string(),
SpeedUnit::Knots => "knots".to_string(),
}
}
pub fn speed_to_string(speed_unit: &SpeedUnit) -> String {
match speed_unit {
SpeedUnit::Kmh => "kmh".to_string(),
SpeedUnit::Ms => "ms".to_string(),
SpeedUnit::Mph => "mph".to_string(),
SpeedUnit::Knots => "kn".to_string(),
}
}