The true power of a great language is the way in which it lets the programmer integrate with types in the standard library and around the general ecosystem. One way to do this is the iterator pattern: defined by the Gang of Four in their book Design Patterns (Addison-Wesley Professional, 1994), an iterator is an encapsulation of a pointer moving through a collection. Rust provides a range of implementations on top of the Iterator trait. Let's see how we can leverage that power with only a few lines of code.
Implementing custom iterators
Getting ready
We will build an iterator for the linked list we built in an earlier recipe. We recommend either using the Chapter01/testing project or walking with us through construction...