Fix bug where kg got parsed as something = kg^-1

This commit is contained in:
Tiffany Bennett 2016-08-02 23:07:36 -04:00
parent 3631c19e04
commit 60380852e6

View file

@ -102,6 +102,11 @@ impl Context {
}
pub fn lookup(&self, name: &str) -> Option<Value> {
for (i, ref k) in self.dimensions.iter().enumerate() {
if name == *k {
return Some(Value::new_unit(1.0, i))
}
}
self.units.get(name).cloned().or_else(|| {
if name.ends_with("s") {
if let Some(v) = self.lookup(&name[0..name.len()-1]) {
@ -116,11 +121,6 @@ impl Context {
}
}
}
for (i, ref k) in self.dimensions.iter().enumerate() {
if name == *k {
return Some(Value::new_unit(1.0, i))
}
}
None
})
}