Allow the calculation of bytes and int.

This commit is contained in:
utam0k 2020-07-12 18:19:07 +09:00
parent d8594a62c2
commit 9c4e3787f5

View File

@ -55,6 +55,16 @@ pub fn compute_values(
}?;
Ok(UntaggedValue::Primitive(Primitive::Filesize(result)))
}
(Primitive::Filesize(x), Primitive::Int(y)) => match operator {
Operator::Plus => Ok(UntaggedValue::Primitive(Primitive::Int(x + y))),
Operator::Minus => Ok(UntaggedValue::Primitive(Primitive::Int(x - y))),
Operator::Multiply => Ok(UntaggedValue::Primitive(Primitive::Int(x * y))),
Operator::Divide => Ok(UntaggedValue::Primitive(Primitive::Decimal(
bigdecimal::BigDecimal::from(x.clone())
/ bigdecimal::BigDecimal::from(y.clone()),
))),
_ => Err((left.type_name(), right.type_name())),
},
(Primitive::Int(x), Primitive::Int(y)) => match operator {
Operator::Plus => Ok(UntaggedValue::Primitive(Primitive::Int(x + y))),
Operator::Minus => Ok(UntaggedValue::Primitive(Primitive::Int(x - y))),