tokio-rs / bytes

Utilities for working with bytes
MIT License
1.86k stars 278 forks source link

Change Bytes::make_mut to impl From<Bytes> for BytesMut #710

Closed nox closed 3 months ago

nox commented 3 months ago

<Arc<T>>::make_mut returns a &mut T, such an API is doable for Bytes too and thus we should reserve Bytes::make_mut for that.

Furthermore, it would be helpful to use From<Bytes> as a trait bound in some cases with other traits such as Hyper's body trait, where Hyper gives you Bytes values.

Finally, making it impl From<Bytes> for BytesMut means the API is more easily discoverable as it appears on both Bytes and BytesMut.

Closes: #709

Darksonn commented 3 months ago

(The marker for what issue you're closing should go in the issue text, not the title. Otherwise github will not auto-close it when I merge the PR.)