Skip to content

Commit

Permalink
Define Eq for Var and Clause based on reference equivalency
Browse files Browse the repository at this point in the history
  • Loading branch information
shnarazk committed Feb 11, 2025
1 parent 02f1d65 commit 47822be
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/types/clause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
};

/// A representation of 'clause'
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd)]
#[derive(Clone, Debug)]
pub struct Clause {
/// The literals in a clause.
pub(crate) lits: Vec<Lit>,
Expand Down Expand Up @@ -85,6 +85,14 @@ impl Default for Clause {
}
}

impl PartialEq for Clause {
fn eq(&self, other: &Self) -> bool {
self == other
}
}

impl Eq for Clause {}

impl Index<usize> for Clause {
type Output = Lit;
#[inline]
Expand Down
6 changes: 6 additions & 0 deletions src/types/var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ impl Default for Var {
}
}

impl PartialEq for Var {
fn eq(&self, other: &Self) -> bool {
self == other
}
}

impl fmt::Display for Var {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let st = |flag, mes| if self.is(flag) { mes } else { "" };
Expand Down

0 comments on commit 47822be

Please sign in to comment.