hyperium / http

Rust HTTP types
Apache License 2.0
1.12k stars 283 forks source link

feat: Add one Grammatical sugar #581

Closed tu6ge closed 1 year ago

tu6ge commented 1 year ago

Examples:

use http::HeaderMap;

fn hello<M: Into<HeaderMap>>(map: M){
    let map: HeaderMap = map.into();
    // more ...
}

// before call it with zero item
use http::HeaderMap;
hello(HeaderMap::new());
// now call it with zero item
hello([]);
seanmonstar commented 1 year ago

Thanks for the PR! However, I don't think having this sugar in the library is what we want. There is the existing FromIterator implementation that helps with this.

tu6ge commented 1 year ago

It suddenly dawned on me, FromIterator is a more abstract From type. Wonderful rust !