Skip to content

Commit a9b4c3e

Browse files
committed
impl Hash for BorrowedStr/BorrowedBytes
1 parent 66557f8 commit a9b4c3e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/string.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ impl AsRef<str> for BorrowedStr {
268268
}
269269
}
270270

271+
impl Hash for BorrowedStr {
272+
fn hash<H: Hasher>(&self, state: &mut H) {
273+
self.buf.hash(state);
274+
}
275+
}
276+
271277
impl fmt::Display for BorrowedStr {
272278
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
273279
self.buf.fmt(f)
@@ -349,6 +355,12 @@ impl AsRef<[u8]> for BorrowedBytes {
349355
}
350356
}
351357

358+
impl Hash for BorrowedBytes {
359+
fn hash<H: Hasher>(&self, state: &mut H) {
360+
self.buf.hash(state);
361+
}
362+
}
363+
352364
impl fmt::Debug for BorrowedBytes {
353365
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
354366
self.buf.fmt(f)

0 commit comments

Comments
 (0)