near_units_core/
prefixes.rs1pub const YOTTA: &str = r"yotta|Y$";
2pub const ZETTA: &str = r"zetta|Z$";
3pub const EXA: &str = r"exa|E$";
4pub const PETA: &str = r"peta|P$";
5pub const TERRA: &str = r"terra|T$";
6pub const GIGA: &str = r"giga|G$";
7pub const MEGA: &str = r"mega|M$";
8pub const KILO: &str = r"kilo|k$";
9pub const HECTO: &str = r"hecto|h$";
10pub const DEKA: &str = r"deka|da$";
11pub const DECI: &str = r"deci|d$";
12pub const CENTI: &str = r"centi|c$";
13pub const MILLI: &str = r"milli|m$";
14pub const MICRO: &str = r"micro|μ$";
15pub const NANO: &str = r"nano|n$";
16pub const PICO: &str = r"pico|p$";
17pub const FEMTO: &str = r"femto|f$";
18pub const ATTO: &str = r"atto|a$";
19pub const ZEPTO: &str = r"zepto|z$";
20pub const YOCTO: &str = r"yocto|y$";
21
22pub const PATTERNS: [&str; 20] = [
23 YOTTA, ZETTA, EXA, PETA, TERRA, GIGA, MEGA, KILO, HECTO, DEKA, DECI, CENTI, MILLI, MICRO, NANO,
24 PICO, FEMTO, ATTO, ZEPTO, YOCTO,
25];
26pub static MAGNITUDES: [i8; 20] = [
27 24, 21, 18, 15, 12, 9, 6, 3, 2, 1, -1, -2, -3, -6, -9, -12, -15, -18, -21, -24,
28];
29
30pub const fn from_magnitude(magnitude: i8) -> Option<&'static str> {
31 match magnitude {
32 24 => Some("Y"),
33 21 => Some("Z"),
34 18 => Some("E"),
35 15 => Some("P"),
36 12 => Some("T"),
37 9 => Some("G"),
38 6 => Some("M"),
39 3 => Some("k"),
40 0 => Some(""),
41 -3 => Some("m"),
42 -6 => Some("μ"),
43 -9 => Some("n"),
44 -12 => Some("p"),
45 -15 => Some("f"),
46 -18 => Some("a"),
47 -21 => Some("z"),
48 -24 => Some("y"),
49 _ => None,
50 }
51}