Skip to content

Commit

Permalink
Improve eq
Browse files Browse the repository at this point in the history
  • Loading branch information
Firstyear committed Jul 6, 2022
1 parent 32fb786 commit bb6f986
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl fmt::Debug for IDLBitRange {
/// let idl_expect = IDLBitRange::from_iter(vec![2]);
/// assert_eq!(idl_result, idl_expect);
/// ```
#[derive(Serialize, Deserialize, PartialEq, Clone)]
#[derive(Serialize, Deserialize, Clone)]
#[serde(rename = "IDLV2")]
pub struct IDLBitRange {
#[serde(rename = "t")]
Expand All @@ -202,6 +202,14 @@ impl Default for IDLBitRange {
}
}

impl PartialEq for IDLBitRange {
fn eq(&self, other: &Self) -> bool {
let x = self & other;
debug_assert!(other.len() == self.len() && other.len() == x.len());
x.len() == other.len()
}
}

impl IDLBitRange {
/// Construct a new, empty set.
pub fn new() -> Self {
Expand Down

0 comments on commit bb6f986

Please sign in to comment.