Skip to content

feat: implement DoubleEndedIterator for tree iterators#103

Open
NikhilSharmaWe wants to merge 2 commits into
sigp:mainfrom
NikhilSharmaWe:feat/double-ended-iterator
Open

feat: implement DoubleEndedIterator for tree iterators#103
NikhilSharmaWe wants to merge 2 commits into
sigp:mainfrom
NikhilSharmaWe:feat/double-ended-iterator

Conversation

@NikhilSharmaWe

Copy link
Copy Markdown
Contributor

Closes #102

Implements DoubleEndedIterator for Iter and InterfaceIter, so list.iter().rev() and next_back() work.

The backward walk mirrors the existing forward iterator: separate stack, same bit-based descent, same PackedLeaf chunk boundary handling in reverse. Pulled the forward logic into a few helpers (descend_to_target, advance_front, retreat_back) rather than duplicating the match arms.

InterfaceIter needed a bit of extra care. When updates are pending, logical length can be ahead of what's actually in the tree (e.g. push without apply). Skipping tree_iter.next_back() for indices past tree_backing_len fixes reverse iteration in that case. Forward does the same skip now too.

Test plan

  • unit tests for .rev(), partial lists, iter_from().rev(), mixed next/next_back, pending push, updates
  • proptest IterRev / IterFromRev

@codecov-commenter

codecov-commenter commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.28829% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.32%. Comparing base (8963bc5) to head (0f501f2).

Files with missing lines Patch % Lines
src/iter.rs 86.17% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #103      +/-   ##
==========================================
+ Coverage   70.15%   72.32%   +2.16%     
==========================================
  Files          22       22              
  Lines        1280     1355      +75     
==========================================
+ Hits          898      980      +82     
+ Misses        382      375       -7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
@NikhilSharmaWe

Copy link
Copy Markdown
Contributor Author

@michaelsproul Could you please take a look?

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.

Investigate implementing DoubleEndedIterator

2 participants