mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 13:44:15 +00:00
Enable dimensionless primitive units
This commit is contained in:
parent
920fffe9ca
commit
c9ad5d9ff0
3 changed files with 2 additions and 4 deletions
|
@ -476,6 +476,7 @@ Hz hertz
|
|||
# "You want:" prompt to tell the user the dimension of the unit.
|
||||
#
|
||||
|
||||
dimensionless ? 1
|
||||
length ? meter
|
||||
area ? length^2
|
||||
volume ? length^3
|
||||
|
|
|
@ -797,7 +797,6 @@ impl Context {
|
|||
},
|
||||
Def::Quantity(ref expr) => match ctx.eval(expr) {
|
||||
Ok(Value::Number(v)) => {
|
||||
println!("Added {}", name);
|
||||
ctx.aliases.insert(v.1, name.clone());
|
||||
},
|
||||
Ok(_) => println!("Quantity {} is not a number", name),
|
||||
|
|
|
@ -278,9 +278,7 @@ pub fn parse(mut iter: &mut Iter) -> Defs {
|
|||
if let Some(Token::Ident(ref _n)) = iter.peek().cloned() {
|
||||
iter.next();
|
||||
// dimensionless primitive unit
|
||||
// not sure what to do with these
|
||||
map.push((name.clone(), Rc::new(Def::Unit(Expr::Const(
|
||||
"1".to_owned(), None, None)))));
|
||||
map.push((name.clone(), Rc::new(Def::Dimension(name))));
|
||||
} else {
|
||||
map.push((name.clone(), Rc::new(Def::Dimension(name))));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue