feat(data-structures/unstable): add Readonly view and clone path to RollingCounter#7161
feat(data-structures/unstable): add Readonly view and clone path to RollingCounter#7161tomas-zijdemans wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7161 +/- ##
=======================================
Coverage 94.83% 94.84%
=======================================
Files 617 618 +1
Lines 51674 51685 +11
Branches 9350 9352 +2
=======================================
+ Hits 49007 49019 +12
Misses 2121 2121
+ Partials 546 545 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bartlomieju
left a comment
There was a problem hiding this comment.
Clean, idiomatic, and well-tested — it mirrors the ReadonlyDeque / Deque.from(deque) precedent member-for-member. I verified the clone equals from(source.toJSON()), is fully independent (#segments reallocated, #total copied), the Pick includes exactly the non-mutating members, and the whole suite + doc examples pass on the branch. The error-message change ("snapshot" → "source") is safe since the throw tests assert error types, not text.
Approving. Two optional polish notes inline; neither is a blocker.
Two additive changes, each adopting a pattern already used by sibling data structures.
ReadonlyRollingCounter, aPick<>view of the non-mutating members.RollingCounternowimplements ReadonlyRollingCounterfor a compile-time guarantee. MatchesReadonlyDequeandReadonlyIndexedHeap.RollingCounter.from()to accept aRollingCounterin addition to aRollingCounterSnapshot. The instance path produces an independent clone with a canonical layout (segments oldest-to-newest, cursor at the last position). MatchesDeque.from(deque)andIndexedHeap.from(otherHeap).No behavior changes for existing call sites.