Temperature Converter
Convert temperatures between Celsius and Fahrenheit.
$$C = (F − 32) \times 5 / 9$$ $$F = (C \times 9 / 5) + 32$$
The tools so far are sufficient to solve this exercise.
As something extra, we implement the Display trait for TemperatureScale enum to output it as strings:
enum TemperatureScale {
Celsius,
Farenheit,
}
impl Display for TemperatureScale {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TemperatureScale::Celsius => write!(f, "Celsius"),
TemperatureScale::Farenheit => write!(f, "Farenheit"),
}
}
}