Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions crates/oxc_span/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ use std::{
/// As an example, In AST types we ignore fields such as [crate::Span].
pub trait ContentHash {
fn content_hash<H: Hasher>(&self, state: &mut H);

/// The default implementation is usually sufficient.
fn content_hash_slice<H: Hasher>(data: &[Self], state: &mut H)
where
Self: Sized,
{
for piece in data {
piece.content_hash(state);
}
}
}

/// Short-Circuting implementation for [Discriminant] since it is used to hash enums.
Expand All @@ -46,7 +36,17 @@ impl<'a, T: ContentHash> ContentHash for oxc_allocator::Box<'a, T> {

impl<'a, T: ContentHash> ContentHash for oxc_allocator::Vec<'a, T> {
fn content_hash<H: Hasher>(&self, state: &mut H) {
ContentHash::content_hash_slice(self.as_slice(), state);
for piece in self {
piece.content_hash(state);
}
}
}

impl<T: ContentHash> ContentHash for [T] {
fn content_hash<H: Hasher>(&self, state: &mut H) {
for piece in self {
piece.content_hash(state);
}
}
}

Expand Down