Skip to content

feat(bytesbuf): add BytesView::to_vec()#495

Open
sandersaares wants to merge 2 commits into
mainfrom
sandersaares/bytesview-to-vec
Open

feat(bytesbuf): add BytesView::to_vec()#495
sandersaares wants to merge 2 commits into
mainfrom
sandersaares/bytesview-to-vec

Conversation

@sandersaares

Copy link
Copy Markdown
Member

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.

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

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.9%. Comparing base (fc13464) to head (ba44ae3).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sandersaares sandersaares marked this pull request as ready for review June 12, 2026 10:53
Copilot AI review requested due to automatic review settings June 12, 2026 10:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 via len() + 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.

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.

4 participants