Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 28, 2024

Conversation

nox
Copy link
Contributor

@nox nox commented May 26, 2024

<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

…-rs#709)

<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.
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@Darksonn Darksonn changed the title Change Bytes::make_mut to impl From<Bytes> for BytesMut (closes #709) Change Bytes::make_mut to impl From<Bytes> for BytesMut May 28, 2024
@Darksonn
Copy link
Contributor

(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.)

@Darksonn Darksonn merged commit fa1daac into tokio-rs:master May 28, 2024
15 checks passed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this missed in review? I don't see any reason for this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@A5rocks A5rocks mentioned this pull request Jul 10, 2024
@mox692 mox692 mentioned this pull request Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider replacing Bytes::make_mut by impl From<Bytes> for BytesMut
3 participants