Added prefix-generating macros

This commit is contained in:
2023-04-13 11:33:51 -07:00
parent 78b0262f61
commit 3948f10bd7
4 changed files with 287 additions and 141 deletions

View File

@ -75,6 +75,37 @@ impl Prefix {
}
macro_rules! str_to_prefix {
("") => {Prefix::None};
("Q") => {Prefix::Quetta};
("R") => {Prefix::Ronna};
("Y") => {Prefix::Yotta};
("Z") => {Prefix::Zetta};
("E") => {Prefix::Exa};
("P") => {Prefix::Peta};
("T") => {Prefix::Tera};
("G") => {Prefix::Giga};
("M") => {Prefix::Mega};
("k") => {Prefix::Kilo};
("h") => {Prefix::Hecto};
("da") => {Prefix::Deka};
("d") => {Prefix::Deci};
("c") => {Prefix::Centi};
("m") => {Prefix::Milli};
("u") => {Prefix::Micro};
("n") => {Prefix::Nano};
("p") => {Prefix::Pico};
("f") => {Prefix::Femto};
("a") => {Prefix::Atto};
("z") => {Prefix::Zepto};
("y") => {Prefix::Yocto};
("r") => {Prefix::Ronto};
("q") => {Prefix::Quecto};
}
pub (super) use str_to_prefix;
impl ToString for Prefix {
fn to_string(&self) -> String {
String::from(match self {
@ -107,4 +138,4 @@ impl ToString for Prefix {
Prefix::None => ""
})
}
}
}