diff --git a/tower-http/src/cors/allow_headers.rs b/tower-http/src/cors/allow_headers.rs index 06c19928..ab0979b0 100644 --- a/tower-http/src/cors/allow_headers.rs +++ b/tower-http/src/cors/allow_headers.rs @@ -1,4 +1,4 @@ -use std::{array, fmt}; +use std::fmt; use http::{ header::{self, HeaderName, HeaderValue}, @@ -86,16 +86,12 @@ impl From for AllowHeaders { } } -impl 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> for AllowHeaders { - fn from(vec: Vec) -> Self { - Self::list(vec) +impl From for AllowHeaders +where + I: IntoIterator, +{ + fn from(iter: I) -> Self { + Self::list(iter) } } diff --git a/tower-http/src/cors/allow_methods.rs b/tower-http/src/cors/allow_methods.rs index df1a3cbd..a2aeb642 100644 --- a/tower-http/src/cors/allow_methods.rs +++ b/tower-http/src/cors/allow_methods.rs @@ -1,4 +1,4 @@ -use std::{array, fmt}; +use std::fmt; use http::{ header::{self, HeaderName, HeaderValue}, @@ -108,8 +108,7 @@ impl From for AllowMethods { impl 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) } } diff --git a/tower-http/src/cors/allow_origin.rs b/tower-http/src/cors/allow_origin.rs index d5fdd7b6..646220fa 100644 --- a/tower-http/src/cors/allow_origin.rs +++ b/tower-http/src/cors/allow_origin.rs @@ -4,7 +4,7 @@ use http::{ }; use pin_project_lite::pin_project; use std::{ - array, fmt, + fmt, future::Future, pin::Pin, sync::Arc, @@ -203,8 +203,7 @@ impl From for AllowOrigin { impl 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) } } diff --git a/tower-http/src/cors/expose_headers.rs b/tower-http/src/cors/expose_headers.rs index 2b1a2267..c16e8224 100644 --- a/tower-http/src/cors/expose_headers.rs +++ b/tower-http/src/cors/expose_headers.rs @@ -1,4 +1,4 @@ -use std::{array, fmt}; +use std::fmt; use http::{ header::{self, HeaderName, HeaderValue}, @@ -69,16 +69,12 @@ impl From for ExposeHeaders { } } -impl 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> for ExposeHeaders { - fn from(vec: Vec) -> Self { - Self::list(vec) +impl From for ExposeHeaders +where + I: IntoIterator, +{ + fn from(iter: I) -> Self { + Self::list(iter) } } diff --git a/tower-http/src/cors/mod.rs b/tower-http/src/cors/mod.rs index 9da666c2..d40994d0 100644 --- a/tower-http/src/cors/mod.rs +++ b/tower-http/src/cors/mod.rs @@ -57,7 +57,6 @@ use http::{ }; use pin_project_lite::pin_project; use std::{ - array, future::Future, mem, pin::Pin, @@ -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 { - #[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, diff --git a/tower-http/src/cors/vary.rs b/tower-http/src/cors/vary.rs index 1ed7e672..9565fd72 100644 --- a/tower-http/src/cors/vary.rs +++ b/tower-http/src/cors/vary.rs @@ -1,5 +1,3 @@ -use std::array; - use http::header::{self, HeaderName, HeaderValue}; use super::preflight_request_headers; @@ -46,15 +44,11 @@ impl Default for Vary { } } -impl 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> for Vary { - fn from(vec: Vec) -> Self { - Self::list(vec) +impl From for Vary +where + I: IntoIterator, +{ + fn from(iter: I) -> Self { + Self::list(iter) } }