Implement hash
This commit is contained in:
parent
1c94f771b2
commit
fc0d17837d
1 changed files with 15 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue