hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.58k stars 1.6k forks source link

Documentation of headerMap should hint from_static for construct header value #2714

Open Stargateur opened 2 years ago

Stargateur commented 2 years ago

The documentation of HeaderMap specially the Exemples section advice to do "example.com".parse().unwrap(), following https://github.com/hyperium/hyper/issues/2713 I suggest the doc should replace the .parse().unwrap() by using HeaderValue::from_static("example.com") that is much better. Or at least mention both until http release a version that require Rust 1.57 since const_panic are stable

paolobarbolini commented 2 years ago

Or at least mention both until http release a version that require Rust 1.57 since const_panic are stable

FWIW from_static doesn't depend on const_panic https://docs.rs/http/latest/src/http/header/value.rs.html#87

Stargateur commented 2 years ago

I was guessing the reason it was not the case it's because the error message is confusing, const_panic should allow a more clear message.