feat(bytesbuf): add BytesView::to_vec()#495
Open
sandersaares wants to merge 2 commits into
Open
Conversation
Adds a method to copy the byte sequence of a BytesView into a new Vec<u8>, leaving the view unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #495 +/- ##
=====================================
Coverage 99.9% 99.9%
=====================================
Files 336 336
Lines 24829 24836 +7
=====================================
+ Hits 24818 24825 +7
Misses 11 11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a convenience API to materialize a BytesView into an owned Vec<u8> by copying all spans in logical order, leaving the view unchanged.
Changes:
- Add
BytesView::to_vec()implemented vialen()+slices()with exact pre-allocation. - Add rustdoc example for
to_vec(). - Add unit tests for empty, single-span, and multi-span views.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Vaiz
approved these changes
Jun 12, 2026
martintmk
approved these changes
Jun 12, 2026
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.
Adds BytesView::to_vec(), which copies the view's full byte sequence into a new Vec.
The method iterates over all spans in logical order via slices(), pre-allocates exact capacity from len(), and leaves the view itself unchanged.
Includes a doctest plus unit tests covering single-span, multi-span, and empty views.