1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
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",
}
)
}
}
|