http-rs / http-types

Common types for HTTP operations
https://docs.rs/http-types
Apache License 2.0
200 stars 83 forks source link

Use string literals instead of manual Url construction in examples #293

Closed yoshuawuyts closed 3 years ago

yoshuawuyts commented 3 years ago

url v2.2.0 has been released which includes a TryFrom<str> for Url impl, which means we can use string literals in our Url examples.

// current
let url = Url::parse("https://github.com/foob").unwrap();
let req = Request::new(url);

// proposed
let req = Request::new("https://github.com/foob");

Both variants will continue to work, and the former case is useful for when dealing with untrusted input. But at least now it should be easier to write examples using Request.

felippemr commented 3 years ago

👋