-
Notifications
You must be signed in to change notification settings - Fork 295
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
Add From Vec<u8> for BytesMut #414
Conversation
I think it's intentional that Lines 735 to 742 in 7daa7fe
|
Right okay. There's a |
@taiki-e If I understand it correctly, you don't want to enable Couldn't this be handled with a deprecation warning instead, if such internal representation change occurs in the future? In that way we could get a fast solution now and a warning if it slows down in the future. I'm asking because we assumed that |
Sorry for the late response.
For example, if we add BytesMut::from(slice.to_vec());
BytesMut::from(&slice); However, if the implementation of
Unfortunately, deprecation doesn't work with trait impl and its items: playground |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to provide an API that relies on From<Vec<u8>>
being cheaper than From<&[u8]>
, so I'll close this PR, but thanks for the patch @leshow!
There could be a special method |
@Kobzol Even if it's deprecatable, I don't think it's preferable to add a new API that is known likely to be deprecated in the future. |
Well it would enable a faster version of this functionality for now, and would also preserve backwards compatibility with users that were already assuming that this fast conversion exists. But I understand if you don't think that's worth it. |
This impl exists for
Bytes
but notBytesMut
, you have to use a&[u8]
which callsto_vec
again when it could just use the original vec.