use std::fmt;
#[derive(Debug, Copy, Clone)]
pub struct RelativeHumidity {
value: f64,
}
impl RelativeHumidity {
pub fn from_percent(pc: f64) -> RelativeHumidity {
RelativeHumidity { value: pc }
}
pub fn as_percent(&self) -> f64 {
self.value
}
}
impl fmt::Display for RelativeHumidity {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:.1}%", self.as_percent())
}
}