Instead of using a for statement, try looping over a custom iterator that
returns an Enum.


On Fri, May 30, 2014 at 11:31 AM, Andrew Poelstra <apoels...@wpsoftware.net>
wrote:

> Hi guys,
>
>
> Take is an iterator adaptor which cuts off the contained iterator after
> some number of elements, always returning None.
>
> I find that I need to detect whether I'm getting None from a Take
> iterator because I've read all of the elements I expected or because the
> underlying iterator ran dry unexpectedly. (Specifically, I'm parsing
> some data from the network and want to detect an early EOM.)
>
>
> This seems like it might be only me, so I'm posing this to the list: if
> there was a function Take::is_done(&self) -> bool, which returned whether
> or not the Take had returned as many elements as it could, would that be
> generally useful?
>
> I'm happy to submit a PR but want to check that this is appropriate for
> the standard library.
>
>
>
> Thanks
>
> Andrew
>
>
>
> --
> Andrew Poelstra
> Mathematics Department, University of Texas at Austin
> Email: apoelstra at wpsoftware.net
> Web:   http://www.wpsoftware.net/andrew
>
> "If they had taught a class on how to be the kind of citizen Dick Cheney
>  worries about, I would have finished high school."   --Edward Snowden
>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to