Solution (source code)

= Solution

Read and advance the <cursor> only when the <iterator> is asked for its next value:

``
def asIter[T](cur: Cursor[T]): Iter[T] = new Iter[T] {
  def hasNext: Boolean = cur.hasCurrent
  def next(): T = {
    require(cur.hasCurrent, "empty iterator")
    val answer = cur.current
    cur.next()
    answer
  }
}
``

The two abstract <sequences> are identical. A `next` call returns the old head and removes it, while `hasNext` only queries availability. No element is read at construction or during an availability test, and no later element is read while returning the current one. Thus the adapter is not too eager. The source's `Cursor.current` clause needs the implicit <precondition> that its <sequence> is nonempty; taking the head of an empty <sequence> is undefined. The checks above satisfy that requirement even without relying on the client convention.