Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions tower-http/src/cors/allow_headers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{array, fmt};
use std::fmt;

use http::{
header::{self, HeaderName, HeaderValue},
Expand Down Expand Up @@ -86,16 +86,12 @@ impl From<Any> for AllowHeaders {
}
}

impl<const N: usize> From<[HeaderName; N]> for AllowHeaders {
fn from(arr: [HeaderName; N]) -> Self {
#[allow(deprecated)] // Can be changed when MSRV >= 1.53
Self::list(array::IntoIter::new(arr))
}
}

impl From<Vec<HeaderName>> for AllowHeaders {
fn from(vec: Vec<HeaderName>) -> Self {
Self::list(vec)
impl<I> From<I> for AllowHeaders
where
I: IntoIterator<Item = HeaderName>,
{
fn from(iter: I) -> Self {
Self::list(iter)
}
}

Expand Down
5 changes: 2 additions & 3 deletions tower-http/src/cors/allow_methods.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{array, fmt};
use std::fmt;

use http::{
header::{self, HeaderName, HeaderValue},
Expand Down Expand Up @@ -108,8 +108,7 @@ impl From<Method> for AllowMethods {

impl<const N: usize> From<[Method; N]> for AllowMethods {
fn from(arr: [Method; N]) -> Self {
#[allow(deprecated)] // Can be changed when MSRV >= 1.53
Self::list(array::IntoIter::new(arr))
Self::list(arr)
}
}

Expand Down
5 changes: 2 additions & 3 deletions tower-http/src/cors/allow_origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use http::{
};
use pin_project_lite::pin_project;
use std::{
array, fmt,
fmt,
future::Future,
pin::Pin,
sync::Arc,
Expand Down Expand Up @@ -203,8 +203,7 @@ impl From<HeaderValue> for AllowOrigin {

impl<const N: usize> From<[HeaderValue; N]> for AllowOrigin {
fn from(arr: [HeaderValue; N]) -> Self {
#[allow(deprecated)] // Can be changed when MSRV >= 1.53
Self::list(array::IntoIter::new(arr))
Self::list(arr)
}
}

Expand Down
18 changes: 7 additions & 11 deletions tower-http/src/cors/expose_headers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{array, fmt};
use std::fmt;

use http::{
header::{self, HeaderName, HeaderValue},
Expand Down Expand Up @@ -69,16 +69,12 @@ impl From<Any> for ExposeHeaders {
}
}

impl<const N: usize> From<[HeaderName; N]> for ExposeHeaders {
fn from(arr: [HeaderName; N]) -> Self {
#[allow(deprecated)] // Can be changed when MSRV >= 1.53
Self::list(array::IntoIter::new(arr))
}
}

impl From<Vec<HeaderName>> for ExposeHeaders {
fn from(vec: Vec<HeaderName>) -> Self {
Self::list(vec)
impl<I> From<I> for ExposeHeaders
where
I: IntoIterator<Item = HeaderName>,
{
fn from(iter: I) -> Self {
Self::list(iter)
}
}

Expand Down
4 changes: 1 addition & 3 deletions tower-http/src/cors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ use http::{
};
use pin_project_lite::pin_project;
use std::{
array,
future::Future,
mem,
pin::Pin,
Expand Down Expand Up @@ -813,8 +812,7 @@ fn ensure_usable_cors_rules(layer: &CorsLayer) {
///
/// This is the default set of header names returned in the `vary` header
pub fn preflight_request_headers() -> impl Iterator<Item = HeaderName> {
#[allow(deprecated)] // Can be changed when MSRV >= 1.53
array::IntoIter::new([
IntoIterator::into_iter([
header::ORIGIN,
header::ACCESS_CONTROL_REQUEST_METHOD,
header::ACCESS_CONTROL_REQUEST_HEADERS,
Expand Down
18 changes: 6 additions & 12 deletions tower-http/src/cors/vary.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::array;

use http::header::{self, HeaderName, HeaderValue};

use super::preflight_request_headers;
Expand Down Expand Up @@ -46,15 +44,11 @@ impl Default for Vary {
}
}

impl<const N: usize> From<[HeaderName; N]> for Vary {
fn from(arr: [HeaderName; N]) -> Self {
#[allow(deprecated)] // Can be changed when MSRV >= 1.53
Self::list(array::IntoIter::new(arr))
}
}

impl From<Vec<HeaderName>> for Vary {
fn from(vec: Vec<HeaderName>) -> Self {
Self::list(vec)
impl<I> From<I> for Vary
where
I: IntoIterator<Item = HeaderName>,
{
fn from(iter: I) -> Self {
Self::list(iter)
}
}