serde-rs / bytes

Wrapper types to enable optimized handling of &[u8] and Vec<u8>
Apache License 2.0
306 stars 37 forks source link

Removing From<Vec<u8>> and From<ByteBuf> was mistake #15

Open misos1 opened 5 years ago

misos1 commented 5 years ago

https://github.com/serde-rs/bytes/commit/f8c4812d1e81f4bb7813fa25c37b52dc3e065741 https://github.com/serde-rs/bytes/commit/f810459d2af103184767050e6181846ed9e12138 https://github.com/serde-rs/bytes/issues/3

They could coexists with ByteBuf::from and ByteBuf::into_vec if you think these functions are clearer in documentation. I never had problems with looking for From trait implementations.

Now is not possible to use it with generic functions which uses things like T: From<Vec<u8>>. There is reason why there are traits like From trait in rust.

And solution to problems like this https://github.com/serde-rs/bytes/issues/14 require even more extra glue code as before.

nathanielc commented 1 year ago

Would a PR to re-add From<Vec<u8>> and From<ByteBuf> be accepted? I have run into the exact case mentioned above where I need ByteBuf to implement the From<Vec<u8>> because it is used as a type parameter to another trait with that constraint.