mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-02-02 09:46:06 +00:00
Merge pull request #594 from gvozdvmozgu/add-box-str-lookup
Some checks are pending
Book / Book (push) Waiting to run
Book / Deploy (push) Blocked by required conditions
Test / Test (false, beta) (push) Waiting to run
Test / Test (false, stable) (push) Waiting to run
Test / Test (true, nightly) (push) Waiting to run
Test / Miri (push) Waiting to run
Test / Benchmarks (push) Waiting to run
Some checks are pending
Book / Book (push) Waiting to run
Book / Deploy (push) Blocked by required conditions
Test / Test (false, beta) (push) Waiting to run
Test / Test (false, stable) (push) Waiting to run
Test / Test (true, nightly) (push) Waiting to run
Test / Miri (push) Waiting to run
Test / Benchmarks (push) Waiting to run
Add `Lookup<Box<T>>` for `&T`
This commit is contained in:
commit
b14be5c039
1 changed files with 16 additions and 0 deletions
|
@ -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 {
|
impl Lookup<String> for &str {
|
||||||
fn hash<H: Hasher>(&self, h: &mut H) {
|
fn hash<H: Hasher>(&self, h: &mut H) {
|
||||||
Hash::hash(self, &mut *h)
|
Hash::hash(self, &mut *h)
|
||||||
|
|
Loading…
Reference in a new issue