Skip to content

feat(builtin): add ReadOnlyArray::chunk_by and suffixes#3610

Merged
bobzhang merged 1 commit into
mainfrom
feat/readonlyarray-chunk-by-suffixes
May 18, 2026
Merged

feat(builtin): add ReadOnlyArray::chunk_by and suffixes#3610
bobzhang merged 1 commit into
mainfrom
feat/readonlyarray-chunk-by-suffixes

Conversation

@bobzhang
Copy link
Copy Markdown
Contributor

Summary

  • Round out the partition/slice family on ReadOnlyArray. Array and ArrayView both expose chunk_by (predicate-based grouping of consecutive elements) and suffixes (iterator over all suffix views, optionally including the empty tail); ReadOnlyArray was missing both.
  • chunk_by returns Array[ArrayView[T]] and suffixes returns Iter[ArrayView[T]], matching the sibling signatures.
  • Implementations route through ArrayView via self[:].
  • Tests cover the classic grouping case, empty input, singleton, and both include_empty=true and the default for suffixes.

Test plan

  • moon check clean
  • moon fmt clean
  • moon test -p moonbitlang/core/builtin — 2842 tests pass

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 18, 2026 04:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds chunk_by and suffixes methods to ReadOnlyArray, delegating to the existing ArrayView implementations to match the API surface already provided on Array and ArrayView.

Changes:

  • Add ReadOnlyArray::chunk_by and ReadOnlyArray::suffixes that route through self[:].
  • Update generated MBTI signatures.
  • Add tests covering classic, empty, singleton, and include_empty cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
builtin/readonlyarray.mbt New chunk_by and suffixes methods delegating to ArrayView.
builtin/readonlyarray_test.mbt Tests for the new methods covering edge cases.
builtin/pkg.generated.mbti Updated public API signatures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 18, 2026

Coverage Report for CI Build 4428

Coverage remained the same at 94.194%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 2 of 2 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: 15881
Covered Lines: 14959
Line Coverage: 94.19%
Coverage Strength: 216256.04 hits per line

💛 - Coveralls

@bobzhang bobzhang force-pushed the feat/readonlyarray-chunk-by-suffixes branch from 749a351 to d1e3f28 Compare May 18, 2026 04:12
Round out the partition/slice family. Array and ArrayView both expose
chunk_by (predicate-based grouping of consecutive elements) and
suffixes (iterator of all suffix views, optionally including the
empty tail); ReadOnlyArray was missing both.

chunk_by returns Array[ArrayView[T]] and suffixes returns
Iter[ArrayView[T]], matching the sibling signatures.

Tests cover the classic grouping case, empty input, singleton, and
both include_empty=true and the default for suffixes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bobzhang bobzhang force-pushed the feat/readonlyarray-chunk-by-suffixes branch from d1e3f28 to 3158101 Compare May 18, 2026 04:23
@bobzhang bobzhang merged commit 6db0984 into main May 18, 2026
14 checks passed
@bobzhang bobzhang deleted the feat/readonlyarray-chunk-by-suffixes branch May 18, 2026 04:30
bobzhang added a commit that referenced this pull request May 18, 2026
PR #3610 (commit 6db0984) accidentally deleted ReadOnlyArray::chunks
and ReadOnlyArray::windows when its rebase conflict over PR #3609 was
resolved by overwriting the chunks/windows block with chunk_by/suffixes
instead of keeping both. The two methods (both source and mbti
entries) had been added in #3609 (c50af5e) one commit earlier.

Restore both methods verbatim from #3609. No other commit in the
recent batch had unpaired removals — all other `-pub fn` lines in
this range are matched signature widenings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

3 participants