summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Fellenz <matt@felle.nz>2024-03-19 02:37:30 -0700
committerGitHub <noreply@github.com>2024-03-19 09:37:30 +0000
commit41db766b83bad4c4671423c03c5e54f308032e7b (patch)
tree323fba5db4cafa162594209666406d6ea39c8164
parentc125125080b00d63c370d72c4fe6229d511f0c89 (diff)
Unify ops match arms (#3720)
-rw-r--r--crates/typst/src/eval/ops.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/typst/src/eval/ops.rs b/crates/typst/src/eval/ops.rs
index 9c20ea0a..4088dbe9 100644
--- a/crates/typst/src/eval/ops.rs
+++ b/crates/typst/src/eval/ops.rs
@@ -498,16 +498,16 @@ pub fn equal(lhs: &Value, rhs: &Value) -> bool {
(Dyn(a), Dyn(b)) => a == b,
// Some technically different things should compare equal.
- (&Int(a), &Float(b)) => a as f64 == b,
- (&Float(a), &Int(b)) => a == b as f64,
- (&Length(a), &Relative(b)) => a == b.abs && b.rel.is_zero(),
- (&Ratio(a), &Relative(b)) => a == b.rel && b.abs.is_zero(),
- (&Relative(a), &Length(b)) => a.abs == b && a.rel.is_zero(),
- (&Relative(a), &Ratio(b)) => a.rel == b && a.abs.is_zero(),
+ (&Int(i), &Float(f)) | (&Float(f), &Int(i)) => i as f64 == f,
+ (&Length(len), &Relative(rel)) | (&Relative(rel), &Length(len)) => {
+ len == rel.abs && rel.rel.is_zero()
+ }
+ (&Ratio(rat), &Relative(rel)) | (&Relative(rel), &Ratio(rat)) => {
+ rat == rel.rel && rel.abs.is_zero()
+ }
// Type compatibility.
- (Type(a), Str(b)) => a.compat_name() == b.as_str(),
- (Str(a), Type(b)) => a.as_str() == b.compat_name(),
+ (Type(ty), Str(str)) | (Str(str), Type(ty)) => ty.compat_name() == str.as_str(),
_ => false,
}