Implement hash

This commit is contained in:
Andras Schmelczer 2026-03-14 11:50:54 +00:00
parent 1c94f771b2
commit fc0d17837d

View file

@ -1,4 +1,7 @@
use std::fmt::Debug;
use std::{
fmt::Debug,
hash::{Hash, Hasher},
};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
@ -78,3 +81,14 @@ where
self.normalized == other.normalized
}
}
/// Hashes based on the `normalized` field only, consistent with the
/// [`PartialEq`] implementation.
impl<T> Hash for Token<T>
where
T: PartialEq + Clone + Debug + Hash,
{
fn hash<H: Hasher>(&self, state: &mut H) {
self.normalized.hash(state);
}
}