1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#[derive(PartialEq, Debug, Clone)] pub struct Sensor { pub sensor_id: String, pub title: Option<String>, } impl Sensor { pub fn display_title(&self) -> &str { if let Some(title) = &self.title { title } else { &self.sensor_id } } }