Slightly off topic, what kind of deserialization are you working on? If
it's a generic deserializer, I'm putting together a prototype for
https://github.com/rust-lang/rfcs/pull/22 in my
https://github.com/erickt/rust-serde repository. Maybe we can collaborate.

On Friday, May 30, 2014, Andrew Poelstra <[email protected]> wrote:

>
> Oh, I sent my earlier message prematurely. The problem here is that I
> want to move the original iterator forward by the appropriate amount
> (not one further), since I'm passing a iter.by_ref() to each of my
> deserialization routines in turn.
>
> It seems that if I use .peekable() I either move the original iterator
> one position too far, or not at all, depending on how exactly I do it.
>
> I could refactor to make my deserialization techniques require a
> Peekable, but this isn't logically necessary because I can accomplish my
> goal by manually counting iterations, so it would be an abstraction
> leak.
>
>
>
> Andrew
>
>
>
> On Fri, May 30, 2014 at 09:57:50AM -0700, Steven Fackler wrote:
> > It may not fulfill your exact use case, but you can get this in a way:
> >
> > let mut foo = bar.iter().peekable();
> > {
> >     let mut limit_foo = foo.by_ref().limit(50);
> >     for baz in limit_foo {
> >         ...
> >     }
> > }
> > if foo.is_empty() {
> >     ...
> > }
> >
> > Steven Fackler
> >
> >
> > On Fri, May 30, 2014 at 9:51 AM, Evan G <[email protected] <javascript:;>>
> wrote:
> >
> > > 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 <
> > > [email protected] <javascript:;>> 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
> > >> [email protected] <javascript:;>
> > >> https://mail.mozilla.org/listinfo/rust-dev
> > >>
> > >>
> > >
> > > _______________________________________________
> > > Rust-dev mailing list
> > > [email protected] <javascript:;>
> > > https://mail.mozilla.org/listinfo/rust-dev
> > >
> > >
>
> --
> 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
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to