Fixed mph/mpg behavior

This commit is contained in:
2023-06-11 15:05:17 -07:00
parent 3294d4d5fb
commit 7382627041
7 changed files with 42 additions and 25 deletions

View File

@ -78,6 +78,8 @@ impl PreToken {
"π"|"pi" => { Some(Constant::Pi)},
"e" => { Some(Constant::E) },
"phi"|"φ" => { Some(Constant::Phi) },
"mpg" => { Some(Constant::MPG) },
"mph" => { Some(Constant::MPH) },
_ => { None }
};

View File

@ -1,17 +1,27 @@
#[derive(Debug)]
#[derive(Clone)]
pub enum Constant {
// Fake units
MPG,
MPH,
// Mathematics
Pi,
Phi,
E
E,
}
impl Constant {
pub fn to_string(&self) -> String {
match self {
// Fake units
Constant::MPG => { String::from("mpg") },
Constant::MPH => { String::from("mph") },
// Mathematics
Constant::Pi => { String::from("π") },
Constant::Phi => { String::from("φ") },
Constant::E => { String::from("e") },
Constant::E => { String::from("e") }
}
}
}