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

Remove unnecessary generic parameter from Set{Request,Response}HeaderLayer #148

Merged
merged 1 commit into from
Nov 15, 2021
Merged

Remove unnecessary generic parameter from Set{Request,Response}HeaderLayer #148

merged 1 commit into from
Nov 15, 2021

Conversation

jplatte
Copy link
Collaborator

@jplatte jplatte commented Oct 4, 2021

Motivation

Currently, SetRequestHeaderLayer and SetResponseHeaderLayer have to have a turbofish supplied when used with a plain HeaderValue (or Option<HeaderValue>) instead of a closure, which is annoying.

Solution

Adjust the generics to make things work out :)

Unfortunately, this conflicts with #147 and as such error messages from closures with wrong parameter types will continue to be reported rather late somewhere in the usage of these layers rather than at the construction site. However, I consider this change to be more valuable than #147.

This is a breaking change because it changes the number of generic parameters and previous ::<_, Body> turbofish usage will thus become invalid.

Properly fixes #127

Copy link
Member

@davidpdrsn davidpdrsn left a comment

Choose a reason for hiding this comment

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

I think this looks good and is worth doing. I've seen several people be confused about the turbofish. Wanna rebase/merge the lastest master and add a note to the changelog? Then it'll be gtm.

@jplatte
Copy link
Collaborator Author

jplatte commented Nov 15, 2021

Done.

@davidpdrsn davidpdrsn merged commit e18fde4 into tower-rs:master Nov 15, 2021
@davidpdrsn
Copy link
Member

Thanks!

@davidpdrsn davidpdrsn mentioned this pull request Dec 1, 2021
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.

SetResponseHeaderLayer et al are hard to use with literal HeaderValues
2 participants