From 958d360ac4c93df6bae4c23704d5b4418fe1d448 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Thu, 20 Oct 2022 21:05:04 +0200 Subject: [PATCH] Generalize `AppendHeaders` to accept any `impl IntoIterator` (#1495) * Generalize `AppendHeaders` to accept any `impl IntoIterator` * changelog --- axum-core/CHANGELOG.md | 2 ++ axum-core/src/response/append_headers.rs | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/axum-core/CHANGELOG.md b/axum-core/CHANGELOG.md index 84673d69..1a64d889 100644 --- a/axum-core/CHANGELOG.md +++ b/axum-core/CHANGELOG.md @@ -9,9 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **added:** Add `DefaultBodyLimit::max` for changing the default body limit ([#1397]) - **added:** Add `Error::into_inner` for converting `Error` to `BoxError` without allocating ([#1476]) +- **breaking:** `AppendHeaders` now works on any `impl IntoIterator` ([#1495]) [#1397]: https://github.com/tokio-rs/axum/pull/1397 [#1476]: https://github.com/tokio-rs/axum/pull/1476 +[#1495]: https://github.com/tokio-rs/axum/pull/1495 # 0.3.0-rc.2 (10. September, 2022) diff --git a/axum-core/src/response/append_headers.rs b/axum-core/src/response/append_headers.rs index d777332f..4f1ae964 100644 --- a/axum-core/src/response/append_headers.rs +++ b/axum-core/src/response/append_headers.rs @@ -30,10 +30,11 @@ use std::fmt; /// } /// ``` #[derive(Debug)] -pub struct AppendHeaders(pub [(K, V); N]); +pub struct AppendHeaders(pub I); -impl IntoResponse for AppendHeaders +impl IntoResponse for AppendHeaders where + I: IntoIterator, K: TryInto, K::Error: fmt::Display, V: TryInto, @@ -44,8 +45,9 @@ where } } -impl IntoResponseParts for AppendHeaders +impl IntoResponseParts for AppendHeaders where + I: IntoIterator, K: TryInto, K::Error: fmt::Display, V: TryInto,