Document subscript[id:] as the preferred id-lookup primitive - #44
Merged
Conversation
0.8.0 shipped O(1) subscript[id:] on Catalog, Lens, and GroupedLens,
but the rules doc still implies users should hand-write
.items.first(where: { $0.id == id }). Add a short section between
load/refresh and Catalog lifecycle pointing readers at the new API
and explaining the filter-aware semantics on lenses.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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
0.8.0 shipped O(1)
subscript[id:]onCatalog,Lens, andGroupedLens(#43), but the rules doc still implies users should hand-write.items.first(where: { \$0.id == id }). Without a mention in the rules file, downstream users naturally reach for the linear-scan idiom — exactly what the PR was designed to obsolete.This adds a short section to
claude/rules/splint.md(betweenload(_:) vs refresh()andCatalog lifecycle) telling readers:catalog[id: id]/lens[id: id]/groupedLens[id: id]— never.items.first(where:).Lens/GroupedLens, a filtered-out item returnsnil(which is almost always what call sites want).Drafted in the voice of the existing sections (rule first, brief why, no code example needed for a trivial subscript surface).
Test plan
🤖 Generated with Claude Code