libcore: add a ScanIterator, a generalisation of MapIterator to have internal state.
auto merge of #5973 : huonw/rust/core-iterator-scan-consumers, r=thestinger

@thestinger r?

~~The 2 `_unlimited` functions are marked `unsafe` since they may not terminate.~~

The `state` fields of the `Unfoldr` and `Scan` iterators are public, since being able to access the final state after the iteration has finished seems reasonable/possibly useful.

~~Lastly, I converted the tests to use `.to_vec`, which halves the amount of code for them, but it means that a `.transform(|x| *x)` call is required on each iterator.~~ 

(removed the 2 commits with `to_vec` and `foldl`.)