From 75cbfd97b75c633c7b200db2a27a3207d8477400 Mon Sep 17 00:00:00 2001 From: AgentElement <38045210+AgentElement@users.noreply.github.com> Date: Wed, 29 May 2024 02:50:04 -0700 Subject: [PATCH] refactor: change match expression in is_isomorphic_to Co-authored-by: ljedrz --- src/term.rs | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/term.rs b/src/term.rs index 8999d75..823d83a 100644 --- a/src/term.rs +++ b/src/term.rs @@ -434,30 +434,15 @@ impl Term { /// /// ``` pub fn is_isomorphic_to(&self, other: &Term) -> bool { - match self { - Var(x) => { - if let Var(y) = other { - x == y - } else { - false - } - } - Abs(p) => { - if let Abs(q) = other { - p.is_isomorphic_to(q) - } else { - false - } - } - App(p_boxed) => { - if let App(q_boxed) = other { - let (ref fp, ref ap) = **p_boxed; - let (ref fq, ref aq) = **q_boxed; - fp.is_isomorphic_to(fq) && ap.is_isomorphic_to(aq) - } else { - false - } + match (self, other) { + (Var(x), Var(y)) => x == y, + (Abs(p), Abs(q)) => p.is_isomorphic_to(q), + (App(p_boxed), App(q_boxed)) => { + let (ref fp, ref ap) = **p_boxed; + let (ref fq, ref aq) = **q_boxed; + fp.is_isomorphic_to(fq) && ap.is_isomorphic_to(aq) } + _ => false, } } }