Skip to content

Conversation

sinder38
Copy link

@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.
🐱 🧈

…` where possible

Remove deprecated `array::IntoIter::new` where `IntoIterator` doesn't fit
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.

1 participant