Skip to content

Conversation

@sinder38
Copy link
Contributor

@sinder38 sinder38 commented Oct 1, 2025

Motivation

I saw multiple instances of:

#[allow(deprecated)] // Can be changed when MSRV >= 1.53

Since the current MSRV is 1.66, these can be simplified.

tower-http's MSRV is 1.66.

This is not strictly a refactor, I replaced some specific array implementations with a blanket implementation.

Solution

Replaced array-based From implementations with a generic, iterable-based approach

// Before:
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))
    }
}

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

For Inner structs supporting conversions from a single item, I kept the singular conversion method and removed deprecated array handling:

impl From<Method> for AllowMethods {
    fn from(method: Method) -> Self {
        Self::exact(method) // Single-item conversion
    }
}

// Removed deprecated array-based impl:
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))
    }
}

This simplifies the code, reduces duplication, and removes no longer necessary #[allow(deprecated)] annotations.
🐱 🧈

Comment on lines 47 to 51
impl<I> From<I> for Vary
where
I: IntoIterator<Item = HeaderName>,
{
fn from(iter: I) -> Self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again.

…` where possible

Remove deprecated `array::IntoIter::new` where `IntoIterator` doesn't fit
@jplatte jplatte force-pushed the refactor/msrv-complience branch from 47e06ee to 652bef6 Compare December 2, 2025 23:20
@jplatte
Copy link
Member

jplatte commented Dec 2, 2025

Sorry for the delay in reviewing this, and thank you for the contribution!

I rebased to see if this still succeeds CI with the changes that have since gone in. But either way I would like to see the blanket-impl changes reverted, as noted above.

Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again!

@jplatte jplatte merged commit 6680160 into tower-rs:main Dec 3, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants