Skip to content

Commit

Permalink
refactor: change match expression in is_isomorphic_to
Browse files Browse the repository at this point in the history
Co-authored-by: ljedrz <ljedrz@users.noreply.github.com>
  • Loading branch information
AgentElement and ljedrz committed May 29, 2024
1 parent eeb36cf commit 2e88700
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down

0 comments on commit 2e88700

Please sign in to comment.