aboutsummaryrefslogtreecommitdiffstats
path: root/src/volume/unit.rs
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2023-01-20 20:04:28 -0330
committerSam Anthony <sam@samanthony.xyz>2023-01-20 20:04:28 -0330
commit3a1e9d081cc299a0ce3e950282464986a36376d9 (patch)
tree1f01505157643ad9b42fd0fc3006126d6e524838 /src/volume/unit.rs
parent413608ea229f0adec21feb27501178ccadd47844 (diff)
downloadvolute-3a1e9d081cc299a0ce3e950282464986a36376d9.zip
refactor volume module
Diffstat (limited to 'src/volume/unit.rs')
-rw-r--r--src/volume/unit.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/volume/unit.rs b/src/volume/unit.rs
new file mode 100644
index 0000000..1b542d3
--- /dev/null
+++ b/src/volume/unit.rs
@@ -0,0 +1,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",
+ }
+ )
+ }
+}