privat/nit — pull request #813 by privat (2014-10-09 00:54:23+00:00)
Title: introduce `Iterator::finish`

While initially playing with for_abuse, an idea was to have the lib informed of an "end of iteration".

When the end of iteration was a result of `is_ok` false, it is easy for the lib to be informed.
But, if for some reason the client chose to abort the loop (with a `break` statement), the lib cannot be informed and some early release of resources cannot occurs.

This PR introduce a new optional service in iterators, namely `finish` that is automatically called at the end of `for` structures.

Currently, there is no user of such a function, but it is a POC that can be used for a nit-version of a `with` structure to implements for_abuse-like controls.

~~~nit
# Simple implementation of the `head` command
var head_limit = 10
for line in read_lines("some file") do
# `read_lines` opens and reads each line
head_limit -= 1
if head_limit < 0 then break
print line
end
# Here the file is automatically closed thanks to finish
~~~