mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 12:56:33 +00:00
fix HashEqLike
for Box<T>
This commit is contained in:
parent
12459c0a9c
commit
567563e131
2 changed files with 17 additions and 2 deletions
|
@ -392,7 +392,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, T> HashEqLike<Box<T>> for &'a T
|
||||
impl<'a, T> HashEqLike<&'a T> for Box<T>
|
||||
where
|
||||
T: ?Sized + Hash + Eq,
|
||||
Box<T>: From<&'a T>,
|
||||
|
@ -400,7 +400,7 @@ where
|
|||
fn hash<H: Hasher>(&self, h: &mut H) {
|
||||
Hash::hash(self, &mut *h)
|
||||
}
|
||||
fn eq(&self, data: &Box<T>) -> bool {
|
||||
fn eq(&self, data: &&T) -> bool {
|
||||
**self == **data
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,11 @@ use expect_test::expect;
|
|||
use std::path::{Path, PathBuf};
|
||||
use test_log::test;
|
||||
|
||||
#[salsa::interned]
|
||||
struct InternedBoxed<'db> {
|
||||
data: Box<str>,
|
||||
}
|
||||
|
||||
#[salsa::interned]
|
||||
struct InternedString<'db> {
|
||||
data: String,
|
||||
|
@ -73,6 +78,16 @@ fn interning_returns_equal_keys_for_equal_data_multi_field() {
|
|||
assert_ne!(s1, new);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn interning_boxed() {
|
||||
let db = salsa::DatabaseImpl::new();
|
||||
|
||||
assert_eq!(
|
||||
InternedBoxed::new(&db, "Hello"),
|
||||
InternedBoxed::new(&db, Box::from("Hello"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn interning_vec() {
|
||||
let db = salsa::DatabaseImpl::new();
|
||||
|
|
Loading…
Reference in a new issue