Skip to content

Commit 77af842

Browse files
tottotoseanmonstar
authored andcommitted
chore(header): make HeaderValue Hash implementation consistent with Eq
1 parent 3311a1a commit 77af842

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/header/value.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use bytes::{Bytes, BytesMut};
33
use std::convert::TryFrom;
44
use std::error::Error;
55
use std::fmt::Write;
6+
use std::hash::{Hash, Hasher};
67
use std::str::FromStr;
78
use std::{cmp, fmt, mem, str};
89

@@ -17,7 +18,7 @@ use crate::header::name::HeaderName;
1718
/// To handle this, the `HeaderValue` is useable as a type and can be compared
1819
/// with strings and implements `Debug`. A `to_str` fn is provided that returns
1920
/// an `Err` if the header value contains non visible ascii characters.
20-
#[derive(Clone, Hash)]
21+
#[derive(Clone)]
2122
pub struct HeaderValue {
2223
inner: Bytes,
2324
is_sensitive: bool,
@@ -617,6 +618,12 @@ impl Error for ToStrError {}
617618

618619
// ===== PartialEq / PartialOrd =====
619620

621+
impl Hash for HeaderValue {
622+
fn hash<H: Hasher>(&self, state: &mut H) {
623+
self.inner.hash(state);
624+
}
625+
}
626+
620627
impl PartialEq for HeaderValue {
621628
#[inline]
622629
fn eq(&self, other: &HeaderValue) -> bool {

0 commit comments

Comments
 (0)