Move ComparisonNumber into the library and add an OwnedLiteral for booleans.
This commit is contained in:
@@ -18,6 +18,13 @@ impl From<&OwnedLiteral> for MathNumber {
|
||||
fn from(original: &OwnedLiteral) -> Self {
|
||||
match original {
|
||||
OwnedLiteral::LString(_) => panic!("Strings should not be cast to numbers for math"),
|
||||
OwnedLiteral::LBoolean(boolean) => {
|
||||
if *boolean {
|
||||
MathNumber::Integer(1)
|
||||
} else {
|
||||
MathNumber::Integer(0)
|
||||
}
|
||||
}
|
||||
OwnedLiteral::LPositiveInteger(num) => {
|
||||
return MathNumber::Integer((*num).try_into().unwrap())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user