feat(builtin): add ReadOnlyArray::chunk_by and suffixes#3610
Merged
Conversation
Contributor
There was a problem hiding this comment.
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_byandReadOnlyArray::suffixesthat route throughself[:]. - Update generated MBTI signatures.
- Add tests covering classic, empty, singleton, and
include_emptycases.
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.
Collaborator
Coverage Report for CI Build 4428Coverage remained the same at 94.194%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
749a351 to
d1e3f28
Compare
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>
d1e3f28 to
3158101
Compare
3 tasks
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>
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.
Summary
ReadOnlyArray.ArrayandArrayViewboth exposechunk_by(predicate-based grouping of consecutive elements) andsuffixes(iterator over all suffix views, optionally including the empty tail);ReadOnlyArraywas missing both.chunk_byreturnsArray[ArrayView[T]]andsuffixesreturnsIter[ArrayView[T]], matching the sibling signatures.ArrayViewviaself[:].include_empty=trueand the default forsuffixes.Test plan
moon checkcleanmoon fmtcleanmoon test -p moonbitlang/core/builtin— 2842 tests pass🤖 Generated with Claude Code