26 lines
592 B
Rust
26 lines
592 B
Rust
use serde::{Deserialize, Serialize};
|
|
use structopt::clap::arg_enum;
|
|
|
|
arg_enum! {
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
|
|
pub enum TempUnit {
|
|
Celsius,
|
|
Fahrenheit
|
|
}
|
|
}
|
|
|
|
pub fn temp_to_unit_string(temp_unit: &TempUnit) -> String {
|
|
match temp_unit {
|
|
TempUnit::Celsius => "°C".to_string(),
|
|
TempUnit::Fahrenheit => "°F".to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn temp_to_string(temp_unit: &TempUnit) -> String {
|
|
match temp_unit {
|
|
TempUnit::Celsius => "celsius".to_string(),
|
|
TempUnit::Fahrenheit => "fahrenheit".to_string(),
|
|
}
|
|
}
|