From ae7736f1341aef94d2ed7f52315c3bdea1d2ab3b Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:52:35 +0000 Subject: [PATCH] Implement `From<&HeaderMap>` for `http::HeaderMap` (#3230) * Add From impl for header map references * Add From impl for header map references * Remove Into via http::HeaderMap * fix changelog --------- Co-authored-by: SleeplessOne1917 Co-authored-by: Rob Ede --- actix-http/CHANGES.md | 4 ++++ actix-http/src/header/map.rs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 994c91a83..3ce06442e 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -2,6 +2,10 @@ ## Unreleased +### Added + +- Implement `From<&HeaderMap>` for `http::HeaderMap`. + ## 3.5.1 ### Fixed diff --git a/actix-http/src/header/map.rs b/actix-http/src/header/map.rs index d8a63b573..b86798a4c 100644 --- a/actix-http/src/header/map.rs +++ b/actix-http/src/header/map.rs @@ -650,6 +650,13 @@ impl From for http::HeaderMap { } } +/// Convert our `&HeaderMap` to a `http::HeaderMap`. +impl From<&HeaderMap> for http::HeaderMap { + fn from(map: &HeaderMap) -> Self { + map.to_owned().into() + } +} + /// Iterator over removed, owned values with the same associated name. /// /// Returned from methods that remove or replace items. See [`HeaderMap::insert`]