Skip to content

Commit

Permalink
Merge pull request #594 from gvozdvmozgu/add-box-str-lookup
Browse files Browse the repository at this point in the history
Add `Lookup<Box<T>>` for `&T`
  • Loading branch information
MichaReiser authored Oct 15, 2024
2 parents cccb7a5 + b6592a8 commit b14be5c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/interned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,22 @@ where
}
}

impl<'a, T> Lookup<Box<T>> for &'a T
where
T: ?Sized + Hash + Eq,
Box<T>: From<&'a T>,
{
fn hash<H: Hasher>(&self, h: &mut H) {
Hash::hash(self, &mut *h)
}
fn eq(&self, data: &Box<T>) -> bool {
**self == **data
}
fn into_owned(self) -> Box<T> {
Box::from(self)
}
}

impl Lookup<String> for &str {
fn hash<H: Hasher>(&self, h: &mut H) {
Hash::hash(self, &mut *h)
Expand Down

0 comments on commit b14be5c

Please sign in to comment.