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

Preserve invalid status code at best effort #336

Closed
wants to merge 1 commit into from

Conversation

upsuper
Copy link
Contributor

@upsuper upsuper commented Aug 13, 2019

This should help on usecases mentioned in #144 without adding performance penalty for everyone else.

Theoretically with the original form, we can use NonZeroU16 and Rust would optimize Result<StatusCode, InvalidStatusCode> to just a u16, which is probably unbeatable. But it isn't clear whether returning Result<u16, ()> could really be faster than Result<u16, u16>.

If that optimization does matter, we can probably hide the new field behind a feature and have people want it to opt in.

@seanmonstar
Copy link
Member

Thanks for the PR! I see now by the implementation you mean to preserve the u16 which is out-of-range in the InvalidStatusCode error type. Do you feel this provides substantial benefits over being able to just look at the original u16 before calling StatusCode::from_u16?

@upsuper
Copy link
Contributor Author

upsuper commented Aug 15, 2019

After some discussion, I don't think this is going to work for the usecase. Closing now.

Sorry for the noise.

@upsuper upsuper closed this Aug 15, 2019
@upsuper upsuper deleted the preserve-invalid branch August 15, 2019 08:06
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