mirror of
https://github.com/tokio-rs/axum.git
synced 2025-01-11 12:31:25 +01:00
Generalize AppendHeaders
to accept any impl IntoIterator
(#1495)
* Generalize `AppendHeaders` to accept any `impl IntoIterator` * changelog
This commit is contained in:
parent
4979b4c9b6
commit
958d360ac4
2 changed files with 7 additions and 3 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -30,10 +30,11 @@ use std::fmt;
|
|||
/// }
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
pub struct AppendHeaders<K, V, const N: usize>(pub [(K, V); N]);
|
||||
pub struct AppendHeaders<I>(pub I);
|
||||
|
||||
impl<K, V, const N: usize> IntoResponse for AppendHeaders<K, V, N>
|
||||
impl<I, K, V> IntoResponse for AppendHeaders<I>
|
||||
where
|
||||
I: IntoIterator<Item = (K, V)>,
|
||||
K: TryInto<HeaderName>,
|
||||
K::Error: fmt::Display,
|
||||
V: TryInto<HeaderValue>,
|
||||
|
@ -44,8 +45,9 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<K, V, const N: usize> IntoResponseParts for AppendHeaders<K, V, N>
|
||||
impl<I, K, V> IntoResponseParts for AppendHeaders<I>
|
||||
where
|
||||
I: IntoIterator<Item = (K, V)>,
|
||||
K: TryInto<HeaderName>,
|
||||
K::Error: fmt::Display,
|
||||
V: TryInto<HeaderValue>,
|
||||
|
|
Loading…
Reference in a new issue