feat(builtin): add ReadOnlyArray::rev_iter#3607
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds reverse iteration support to ReadOnlyArray to match existing APIs on Array, ArrayView, MutArrayView, and FixedArray-based iter chains.
Changes:
- Introduce
ReadOnlyArray::rev_iter()implemented viaself[:].rev_iter(). - Add regression tests covering both non-empty and empty
ReadOnlyArrayreverse iteration. - Update generated builtin package interface (
pkg.generated.mbti) to export the new method.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| builtin/readonlyarray.mbt | Adds ReadOnlyArray::rev_iter() with documentation/example. |
| builtin/readonlyarray_test.mbt | Extends iterator/sub-slicing test to cover rev_iter() on non-empty and empty arrays. |
| builtin/pkg.generated.mbti | Exposes the new ReadOnlyArray::rev_iter signature in the generated interface. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// arr.rev_iter().each(x => result.push(x)) | ||
| /// debug_inspect(result, content="[3, 2, 1]") | ||
| /// } | ||
| /// ``` |
Collaborator
Coverage Report for CI Build 4419Coverage increased (+0.001%) to 94.193%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
883538b to
fe65432
Compare
Array, ArrayView, MutArrayView, and FixedArray.iter() chain (via Iter::rev — note Iter does not have rev) — all expose `rev_iter`, which produces an iterator from last element to first. ReadOnlyArray already had `iter` and `iter2` but not the reverse counterpart. Implementation delegates to ArrayView::rev_iter via `self[:]`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fe65432 to
51a0d5a
Compare
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
Array,ArrayView,MutArrayView, andFixedArray(via its iter chain) all exposerev_iterto walk from the last element to the first.ReadOnlyArrayhaditeranditer2but not the reverse counterpart.ArrayView::rev_iterviaself[:].Test plan
moon checkcleanmoon fmtcleanmoon test -p moonbitlang/core/builtin— 2833 tests pass (covers non-empty + empty cases)🤖 Generated with Claude Code