You are assuming that `getindex` exists, which may not be true for iterables.

To be completely general, you need to use the `start`, `done`, `next` iteration protocol.