Skip to content

Commit 77b1a56

Browse files
committed
Add implementations for Lookup and HashEqLike for CompactString
1 parent a0e7a06 commit 77b1a56

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/interned.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,13 @@ impl Lookup<String> for &str {
12781278
}
12791279
}
12801280

1281+
#[cfg(feature = "compact_str")]
1282+
impl Lookup<compact_str::CompactString> for &str {
1283+
fn into_owned(self) -> compact_str::CompactString {
1284+
compact_str::CompactString::new(self)
1285+
}
1286+
}
1287+
12811288
impl HashEqLike<&str> for String {
12821289
fn hash<H: Hasher>(&self, h: &mut H) {
12831290
Hash::hash(self, &mut *h)
@@ -1288,6 +1295,17 @@ impl HashEqLike<&str> for String {
12881295
}
12891296
}
12901297

1298+
#[cfg(feature = "compact_str")]
1299+
impl HashEqLike<&str> for compact_str::CompactString {
1300+
fn hash<H: Hasher>(&self, h: &mut H) {
1301+
Hash::hash(self, &mut *h)
1302+
}
1303+
1304+
fn eq(&self, data: &&str) -> bool {
1305+
self == *data
1306+
}
1307+
}
1308+
12911309
impl<A, T: Hash + Eq + PartialEq<A>> HashEqLike<&[A]> for Vec<T> {
12921310
fn hash<H: Hasher>(&self, h: &mut H) {
12931311
Hash::hash(self, h);

0 commit comments

Comments
 (0)