Skip to content

refactor(sorted_map): rename keys_as_iter/values_as_iter to keys/values#3591

Merged
bobzhang merged 3 commits into
mainfrom
refactor/sorted-map-keys-values-iter
May 14, 2026
Merged

refactor(sorted_map): rename keys_as_iter/values_as_iter to keys/values#3591
bobzhang merged 3 commits into
mainfrom
refactor/sorted-map-keys-values-iter

Conversation

@bobzhang
Copy link
Copy Markdown
Contributor

Summary

  • Complete the planned breaking change announced in the previous #deprecated notices: SortedMap::keys/values now return Iter[K]/Iter[V] instead of Array, taking over the names from keys_as_iter/values_as_iter.
  • Preserve back-compat by exposing the old _as_iter names as deprecated aliases via #alias(..., deprecated).
  • Update internal callers (README.mbt.md, map_test.mbt) so the package builds without deprecation warnings.

Test plan

  • moon check — clean, no warnings
  • moon test — full suite (6476 tests) passes

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 14, 2026 01:52
@bobzhang bobzhang enabled auto-merge (rebase) May 14, 2026 01:53
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 14, 2026

Coverage Report for CI Build 4355

Coverage remained the same at 94.275%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15809
Covered Lines: 14904
Line Coverage: 94.28%
Coverage Strength: 217231.35 hits per line

💛 - Coveralls

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

This PR completes a previously announced breaking API change in sorted_map: SortedMap::keys() and SortedMap::values() now return iterators (Iter[K] / Iter[V]) instead of arrays, and the old *_as_iter names are preserved as deprecated aliases.

Changes:

  • Renamed keys_as_iterkeys and values_as_itervalues (iterator-returning APIs).
  • Added deprecated aliases so keys_as_iter / values_as_iter continue to exist.
  • Updated documentation and tests to use keys() / values() and avoid deprecation warnings.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
sorted_map/README.mbt.md Updates examples to use keys() / values() iterator APIs.
sorted_map/map.mbt Renames iterator APIs and adds deprecated aliases for legacy names.
sorted_map/map_test.mbt Updates tests to call keys() / values() instead of deprecated names.
sorted_map/deprecated.mbt Removes the old deprecated array-returning keys() / values() methods.

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

Comment thread sorted_map/map.mbt
Comment on lines 268 to +296
@@ -291,7 +292,8 @@ pub fn[K, V] SortedMap::keys_as_iter(self : SortedMap[K, V]) -> Iter[K] {

///|
/// Returns an iterator over the values in ascending key order.
pub fn[K, V] SortedMap::values_as_iter(self : SortedMap[K, V]) -> Iter[V] {
#alias(values_as_iter, deprecated)
pub fn[K, V] SortedMap::values(self : SortedMap[K, V]) -> Iter[V] {
bobzhang and others added 3 commits May 14, 2026 10:20
Complete the planned breaking change announced in the previous
`#deprecated` notices: `SortedMap::keys`/`values` now return `Iter[K]`/
`Iter[V]` instead of `Array`, taking over the names from `keys_as_iter`
and `values_as_iter`. The old `_as_iter` names remain as deprecated
aliases via `#alias(..., deprecated)`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bobzhang bobzhang force-pushed the refactor/sorted-map-keys-values-iter branch from 60deca2 to e51b1ce Compare May 14, 2026 02:20
@bobzhang bobzhang merged commit 46ee4c3 into main May 14, 2026
14 checks passed
@bobzhang bobzhang deleted the refactor/sorted-map-keys-values-iter branch May 14, 2026 02:26
bobzhang added a commit that referenced this pull request May 15, 2026
…forms

Completes the planned breaking change announced in the existing `#deprecated`
notices: `SortedMap::map`/`fold`/`filter` now accept the full `(K, X) -> Y`,
`(A, K, V) -> A`, `(K, V) -> Bool` shapes, taking over the names from
`map_with_key`/`foldl_with_key`/`filter_with_key`.

Mirrors the same migration already done on `@immut/hashmap` (see
`immut/hashmap/HAMT.mbt:171,214,237`) and the very recent rename on the
mutable `@sorted_map` in #3591.

- the long `_with_key` names are kept as deprecated aliases via
  `#alias(<name>_with_key, deprecated)` so existing callers keep compiling
- removes the placeholder deprecated `map`/`fold`/`filter` stubs in
  `immut/sorted_map/deprecated.mbt` that were reserving the short names
- updates the one internal external caller
  (`internal/regex_engine/automata/mark_slot_map.mbt`) and the package
  README / tests so the workspace builds without deprecation warnings

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