So, the list of requirements got expanded:
- Move forward through the log
- Move backward through the log
- Moves don't consume the log
A nice fit for the doubly linked list, so the existing transaction log can be upgraded! With the pointers to both neighbors of a node, it can solve the problem. However, what about moving through the list without removing elements?
For that, another concept is required: iterators. Rust's iterators are leaning on the functional side of programming and provide a versatile interface for integrating with all kinds of other data structures and commands across the language. For example, for loops will pick up on the iterator and behave as expected.
Iterators are pointers to the current item with a method called next() that produces the next item while moving the pointer forward! This concept is applied a lot when using a more functional approach to working with collections: by chaining them together and applying a function after...