From 25d2dc1ba198d5e11704fc4a5252ef0c10f0dd6f Mon Sep 17 00:00:00 2001 From: Marten Wijnja Date: Tue, 26 Nov 2024 07:52:21 +0100 Subject: [PATCH] Generalize HeaderMap's TryFrom impl from HashMap, to allow other hashing functions Fixes #726 --- src/header/map.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/header/map.rs b/src/header/map.rs index a668b311..7610175b 100644 --- a/src/header/map.rs +++ b/src/header/map.rs @@ -2020,7 +2020,7 @@ impl FromIterator<(HeaderName, T)> for HeaderMap { /// let headers: HeaderMap = (&map).try_into().expect("valid headers"); /// assert_eq!(headers["X-Custom-Header"], "my value"); /// ``` -impl<'a, K, V, T> TryFrom<&'a HashMap> for HeaderMap +impl<'a, K, V, S, T> TryFrom<&'a HashMap> for HeaderMap where K: Eq + Hash, HeaderName: TryFrom<&'a K>, @@ -2030,7 +2030,7 @@ where { type Error = Error; - fn try_from(c: &'a HashMap) -> Result { + fn try_from(c: &'a HashMap) -> Result { c.iter() .map(|(k, v)| -> crate::Result<(HeaderName, T)> { let name = TryFrom::try_from(k).map_err(Into::into)?;