Closed gmacon closed 2 years ago
I've now found Limits of Lifetimes in the 'Nomicon, which implies that what I'm asking for here is impossible without changing the API. After thinking about it, I've realized that this doesn't cause a problem for streaming_iterator
because there are no additional useful methods to call on a StreamingIterator
, so you can't notice that you can't call anything else.
I have code that boils down to
which fails with this error:
I tried using the same trick as streaming_iterator, which is splitting
next(&mut self) -> Result<Packet, Error>
intoadvance(&mut self)
andget(&self) -> Result<Packet, Error>
, but that didn't help.Edited to add: my attempt is at https://github.com/gmacon/pcap/tree/shared-borrow-next
Does anyone know a way of telling the Rust compiler that the result of
next
is a shared borrow ofself
instead of a mutable borrow?If I should ask this question in a different forum, please let me know.