hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Documentation of headerMap should hint from_static for construct header value

Open Stargateur opened this issue 3 years ago • 2 comments

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

Stargateur avatar Dec 03 '21 14:12 Stargateur

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

paolobarbolini avatar Dec 03 '21 14:12 paolobarbolini

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.

Stargateur avatar Dec 03 '21 15:12 Stargateur