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

HeaderMap docs show using a string value #71

Closed
seanmonstar opened this issue Jul 31, 2017 · 4 comments
Closed

HeaderMap docs show using a string value #71

seanmonstar opened this issue Jul 31, 2017 · 4 comments
Labels
A-headers Area: HTTP headers E-easy Effort: easy. Start here :D

Comments

@seanmonstar
Copy link
Member

The documentation of HeaderMap shows using strings for values, which works in the doc tests because HeaderMap<T> is generic over the value. However, if people try to use the same examples in real code, it won't work, because Request and Response both use HeaderMap<HeaderValue>. The docs should probably be updated to show using HeaderValues.

I also kind of wonder if the generic T will cause problems elsewhere. If someone just needs to view some headers, and writes &HeaderMap, and sees the complaint about a missing generic, will they easily be able to determine it should be &HeaderMap<HeaderValue?

Should we export a type alias instead?

@seanmonstar seanmonstar added this to the 0.1 milestone Jul 31, 2017
@carllerche
Copy link
Collaborator

It looks like this will be fixed as part of #86?

@seanmonstar
Copy link
Member Author

No, the docs still show using a HeaderMap<&'static str>.

@carllerche
Copy link
Collaborator

Docs can be fixed post 0.1, so I will remove the milestone.

@carllerche carllerche removed this from the 0.1 milestone Aug 12, 2017
carllerche added a commit that referenced this issue Aug 16, 2017
Most of the time, `HeaderMap` is expected to be used with `HeaderValue`.
THere are some cases in which it is useful to use a custom value type,
but setting a default for `T` improves the 99% case.

Fixes #90, #71
carllerche added a commit that referenced this issue Aug 16, 2017
Most of the time, `HeaderMap` is expected to be used with `HeaderValue`. There are some cases in which it is useful to use a custom value type, but setting a default for `T` improves the 99% case.

Fixes #90, #71
@seanmonstar
Copy link
Member Author

This is pretty much done. Glancing through, it looks like HeaderMap::get_mut shows using a String instead of HeaderValue, but since you can't mutate a HeaderValue, it'd be a less useful example...

@seanmonstar seanmonstar added A-headers Area: HTTP headers E-easy Effort: easy. Start here :D labels Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-headers Area: HTTP headers E-easy Effort: easy. Start here :D
Projects
None yet
Development

No branches or pull requests

2 participants