On Thursday, February 13, 2014, Gábor Lehel
<glaebho...@gmail.com<javascript:_e(%7B%7D,'cvml','glaebho...@gmail.com');>>
wrote:

>
>
> This is not strictly true.
>
> If instead of
>
>     fn next(&mut self) -> Option<A>;
>
> we had something like
>
>     fn next(self) -> Option<(Self, A)>;
>
> then access to exhausted iterators would be ruled out at the type level.
>
> (But it's more cumbersome to work with and is currently incompatible with
> trait objects.)
>


This is an appealing option. If it is really this simple to close this
undefined behavior, I think we should consider it. Are there any other
downsides? Does it optimize down to the same code as our current iterators?
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to