valkyrie_std_units/
lib.rs

1use std::fmt::Display;
2
3pub struct SIQuantities<T> {
4    pub value: T,
5    pub name: SIUnit,
6}
7
8// length, mass, time, electric current, thermodynamic temperature, amount of substance, and luminous intensity
9pub struct SIUnit {
10    // common name
11    pub name: String,
12    //
13    pub length: i8,
14    //
15    pub mass: i8,
16    pub time: i8,
17    // electric current
18    pub current: i8,
19    // thermodynamic temperature
20    pub thermodynamic: i8,
21    // amount of substance
22    pub amount: i8,
23    // luminous intensity
24    pub luminous: i8,
25}
26
27impl Display for SIUnit {
28    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29        if !self.name.is_empty() {
30            return f.write_str(&self.name);
31        }
32        write!(
33            f,
34            "({}, {}, {}, {}, {}, {}, {})",
35            self.length,
36            self.mass,
37            self.time,
38            self.current,
39            self.thermodynamic,
40            self.amount,
41            self.luminous,
42        )
43    }
44}