Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap LanguageTags type in new AnyOrSome type to support wildcards #2480

Merged
merged 8 commits into from
Dec 2, 2021

Conversation

robjtede
Copy link
Member

@robjtede robjtede commented Dec 1, 2021

PR Type

Fix

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

Overview

Introduce new AnyOrSome (bikeshedding welcome) wrapper type to support wildcard items in header types where the backing type has no concept of wildcard/any types.

Used initially in AcceptLanguage but for consistency it might make sense to re-work Accept (which does know about wildcards).

fixes #2434

@robjtede robjtede added A-web project: actix-web B-semver-major breaking change requiring a major version bump labels Dec 1, 2021
@robjtede robjtede requested a review from a team December 1, 2021 19:43
@robjtede
Copy link
Member Author

robjtede commented Dec 1, 2021

cc @Dexterp37

@robjtede robjtede changed the title wrap LanguageTags type in new AnyOrSome type to support wildcards wrap LanguageTags type in new AnyOrSome type to support wildcards Dec 1, 2021
@robjtede robjtede mentioned this pull request Dec 2, 2021
4 tasks
@finnbear
Copy link

finnbear commented Dec 2, 2021

Introduce new AnyOrSome (bikeshedding welcome)

I assume you are trying to avoid a compound-word name. Here are some ideas:

  1. Preference<T>
enum Preference<T> {
    Any,
    Specific(T)
}
  1. Just use Option<T> where None is taken to mean nothing specific i.e. any
  2. Other considered enum names: Specificity<T>

@robjtede
Copy link
Member Author

robjtede commented Dec 2, 2021

  1. I kinda like Preference<T>
  2. Nah, the None variant would be confusing.
  3. it's alright, just a bit harder to spell/type than preference

@robjtede robjtede merged commit 075d871 into master Dec 2, 2021
@robjtede robjtede deleted the fix-accept-lang branch December 2, 2021 13:59
@robjtede robjtede added this to the actix-web v4 milestone Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web project: actix-web B-semver-major breaking change requiring a major version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"any language" (* - wildcard) does not get parsed for the Accept-Language header
2 participants