diff --git a/src/interned.rs b/src/interned.rs index 01f39c9a7..1f1bd0dfe 100644 --- a/src/interned.rs +++ b/src/interned.rs @@ -6,6 +6,7 @@ use std::hash::{BuildHasher, Hash, Hasher}; use std::marker::PhantomData; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicU8, Ordering}; +use std::sync::Arc; use dashmap::SharedValue; @@ -542,6 +543,29 @@ where } } +impl<'a, T> HashEqLike<&'a T> for Arc +where + T: ?Sized + Hash + Eq, + Arc: From<&'a T>, +{ + fn hash(&self, h: &mut H) { + Hash::hash(self, &mut *h) + } + fn eq(&self, data: &&T) -> bool { + **self == **data + } +} + +impl<'a, T> Lookup> for &'a T +where + T: ?Sized + Hash + Eq, + Arc: From<&'a T>, +{ + fn into_owned(self) -> Arc { + Arc::from(self) + } +} + impl Lookup for &str { fn into_owned(self) -> String { self.to_owned()