Skip to content

feat(builtin): add ArrayView::strip_prefix and strip_suffix#3430

Open
bobzhang wants to merge 1 commit intomainfrom
hongbo/ArrayView_strip
Open

feat(builtin): add ArrayView::strip_prefix and strip_suffix#3430
bobzhang wants to merge 1 commit intomainfrom
hongbo/ArrayView_strip

Conversation

@bobzhang
Copy link
Copy Markdown
Contributor

@bobzhang bobzhang commented Apr 15, 2026

Summary

  • Add ArrayView::strip_prefix and ArrayView::strip_suffix, returning ArrayView[T]?.
  • Unlike Array's versions (which allocate a new array), the view variants are O(1) sub-views — matching the StringView precedent.

Test plan

  • moon fmt, moon check, moon info
  • moon test -p moonbitlang/core/builtin — 2746/2746 pass
  • Covers: basic match/no-match, empty prefix/suffix, full-length match, prefix/suffix longer than view, sliced-view case, and a backing-array sharing test (mutating source reflects in stripped view).

🤖 Generated with Claude Code


Open with Devin

Copy link
Copy Markdown

@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 2 additional findings.

Open in Devin Review

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 15, 2026

Coverage Report for CI Build 3816

Coverage increased (+0.002%) to 95.009%

Details

  • Coverage increased (+0.002%) from the base build.
  • Patch coverage: 6 of 6 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15448
Covered Lines: 14677
Line Coverage: 95.01%
Coverage Strength: 219778.83 hits per line

💛 - Coveralls

@bobzhang bobzhang force-pushed the hongbo/ArrayView_strip branch 3 times, most recently from 0b18ae2 to ce369b3 Compare April 15, 2026 08:06
Mirror Array::strip_prefix / strip_suffix on ArrayView. The view variants
return ArrayView[T]? (a sub-view) rather than allocating, matching the
StringView precedent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bobzhang bobzhang force-pushed the hongbo/ArrayView_strip branch from ce369b3 to 59ca09d Compare April 16, 2026 01:47
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.

2 participants