On 13/02/2014 16:09, Olivier Renaud wrote:
As you said, the type system can not enforce this rule, that's why
the documentation have no choice but to say the behavior is undefined.

Just because we can not make them automatically-enforced rules doesn’t mean we can’t have conventions. I’m suggesting that we adopt a convention that iterators *should* be well-behaved.


If the code you write relies on None being returned forever, then you
should use the Fuse iterator adaptor, that wraps an existing iterator
and enforces this behavior:

http://static.rust-lang.org/doc/master/std/iter/trait.Iterator.html#method.fuse
http://static.rust-lang.org/doc/master/guide-container.html#iterator-adaptors

--
Simon Sapin
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to