feat(buffer): allow Buffer::into_mutable to return for sliced buffer from the middle and add Buffer::is_sliced helper#10116
Closed
rluvaton wants to merge 4 commits into
Closed
Conversation
from the middle and add `Buffer::is_sliced` helper before, `Buffer::into_mutable` would panic if you pass it `Buffer` that was offseted from the underlying bytes, but it would be ok for sliced `Buffer` that start at the same position but ends before the data itself
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
N/A
Rationale for this change
before,
Buffer::into_mutablewould panic if you pass itBufferthat was offseted from the underlying bytes, but it would be ok for slicedBufferthat start at the same position but ends before the data_ptr itself, so the mutable buffer had data that was outside the slice in that case.this would allow sliced buffer to be converted to
MutableBuffer.if they don't want to convert to
MutableBufferfor slicedBufferthey can call the newis_slicedfunction before.What changes are included in this PR?
added
Buffer::is_slicedfunction and remove the panic if callingBuffer::into_mutableon owned sliced (wheredata_ptris notptrin theBuffer)BufferAre these changes tested?
Yes
Are there any user-facing changes?
Yes, new function and allowed for converting the entire buffer including data outside the slice to mutable