It is a common idiom to have a struct type with a next function with an
optional in its return type, so that the function may return a null to indicate
that iteration is finished.
Some iterators have a !?T return type, as opposed to ?T. !?T requires that
we unpack the error union before the optional, meaning that the work done to get
to the next iteration may error. Here is an example of doing this with a loop.
cwd has to be
opened with iterate permissions for the directory iterator to work.
Here we will implement a custom iterator. This will iterate over a slice of
strings, yielding the strings which contain a given string.