hyperium / http

Rust HTTP types
Apache License 2.0
1.16k stars 291 forks source link

Can `http::{response,request}::Builder::body` take `Into<T>` instead of `T` #401

Closed rylev closed 4 years ago

rylev commented 4 years ago

This would allow the user to write:

let response: Response<Body> = Response::builder().body("hello");

instead of:

let response: Response<Body> = Response::builder().body(Body::from("hello"));

I don't believe this breaks existing code because of impl<T> From<T> for T

jplatte commented 4 years ago

I don't believe this breaks existing code because of impl<T> From<T> for T

This would break existing code where the type of the expression inside .body() is inferred frmo bodys signature, e.g.

let response: Response<Body> = Response::builder().body("hello".into());
seanmonstar commented 4 years ago

I believe this would also require the function to take 2 generics instead of one.