use std::fmt::{self, Display, Formatter}; #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] pub enum Unit { CubicMetre, #[default] Litre, CubicCentimetre, } impl Unit { pub const ALL: [Self; 3] = [Self::CubicMetre, Self::Litre, Self::CubicCentimetre]; } impl Display for Unit { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!( f, "{}", match self { Self::CubicMetre => "m³", Self::Litre => "L", Self::CubicCentimetre => "cc", } ) } }