Skip to content

Commit

Permalink
refactor(restricted_glob): add Eq impls (#4388)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos authored Oct 25, 2024
1 parent 28a2a6c commit 3cef1f2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/biome_js_analyze/src/utils/restricted_glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,21 @@ impl RestrictedGlob {
self.glob.is_match_candidate(&path.0)
}
}
impl PartialEq for RestrictedGlob {
fn eq(&self, other: &Self) -> bool {
self.is_negated == other.is_negated && self.glob.glob() == other.glob.glob()
}
}
impl Eq for RestrictedGlob {}
impl std::hash::Hash for RestrictedGlob {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.is_negated.hash(state);
self.glob.glob().hash(state);
}
}
impl std::fmt::Display for RestrictedGlob {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let repr = self.glob.glob().to_string();
let repr = self.glob.glob();
let negation = if self.is_negated { "!" } else { "" };
write!(f, "{negation}{repr}")
}
Expand Down

0 comments on commit 3cef1f2

Please sign in to comment.