Ropey iterators operate as a cursor positioned between elements. You move the cursor using next() or prev() to jump over an element and receive it.
Directional Control
next(): Moves the cursor forward.prev(): Moves the cursor backward.reverse(): Swaps the behavior of next() and prev() in-place without changing the current position.reversed(): A builder-pattern method that calls reverse() and returns the iterator, useful for chaining.
Note: Ropey's reverse() is different from Rust's DoubleEndedIterator::rev(). While rev() switches between two iterators starting at opposite ends, Ropey's reverse() simply flips the direction of the existing cursor at its current position.
Positioning
Iterators can be created at any specific position using methods like bytes_at(), chars_at(), or lines_at(). When created at a position, the first call to next() returns the element at that position, and the first call to prev() returns the element immediately preceding it. Even if created at a specific index, the iterator retains access to the full contents of the Rope or RopeSlice (e.g., you can create a Chars iterator at the end of a rope and use prev() to traverse backwards to the beginning).