diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index fc49bc931..eadd5c515 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -5,6 +5,7 @@ ### Changed - Updated `zstd` dependency to `0.13`. +- Implemented `From` for `http::HeaderMap`. ### Fixed diff --git a/actix-http/src/header/map.rs b/actix-http/src/header/map.rs index e8118be93..d8a63b573 100644 --- a/actix-http/src/header/map.rs +++ b/actix-http/src/header/map.rs @@ -636,10 +636,17 @@ impl<'a> IntoIterator for &'a HeaderMap { } } -/// Convert `http::HeaderMap` to our `HeaderMap`. +/// Convert a `http::HeaderMap` to our `HeaderMap`. impl From for HeaderMap { - fn from(mut map: http::HeaderMap) -> HeaderMap { - HeaderMap::from_drain(map.drain()) + fn from(mut map: http::HeaderMap) -> Self { + Self::from_drain(map.drain()) + } +} + +/// Convert our `HeaderMap` to a `http::HeaderMap`. +impl From for http::HeaderMap { + fn from(map: HeaderMap) -> Self { + Self::from_iter(map) } }