Skip to content

Add BytesView constructors and unchecked string conversion#3200

Open
bobzhang wants to merge 1 commit intomainfrom
codex/check-consistency-between-bytes-and-bytesview
Open

Add BytesView constructors and unchecked string conversion#3200
bobzhang wants to merge 1 commit intomainfrom
codex/check-consistency-between-bytes-and-bytesview

Conversation

@bobzhang
Copy link
Contributor

@bobzhang bobzhang commented Feb 2, 2026

Motivation

  • Align BytesView API with Bytes by providing constructors and the unchecked string helper that mirror Bytes counterparts.
  • Expose the new BytesView helpers in the builtins interface so external code can use them without workarounds.

Description

  • Added BytesView::from_array(ArrayView[Byte]) -> BytesView to construct a view from an array by delegating to Bytes::from_array(... )[:].
  • Added BytesView::from_iter(Iter[Byte]) -> BytesView (declared with #alias(from_iterator, deprecated)) to construct a view from an iterator by delegating to Bytes::from_iter(... )[:].
  • Added BytesView::to_unchecked_string(self, offset? : Int, length? : Int) -> String which delegates to Bytes::to_unchecked_string using the view start offset and validates bounds.
  • Regenerated the builtin package interface (pkg.generated.mbti) so the new BytesView APIs are published.

Testing

  • Ran moon info which completed successfully and updated the generated interface without errors.
  • Ran moon fmt which completed successfully and formatted the modified files.

Codex Task


Open with Devin

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional flags.

Open in Devin Review

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 2526

Details

  • 0 of 5 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 95.952%

Changes Missing Coverage Covered Lines Changed/Added Lines %
builtin/bytesview.mbt 0 5 0.0%
Totals Coverage Status
Change from base Build 2524: -0.04%
Covered Lines: 11448
Relevant Lines: 11931

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants