From 300f91da35009a8db8071258bb21794741b7b6a0 Mon Sep 17 00:00:00 2001 From: Qqwy / Marten Date: Tue, 26 Nov 2024 14:14:00 +0100 Subject: [PATCH] Generalize HeaderMap's TryFrom impl from HashMap, to allow other hashing functions (#729) 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)?;