Whenever I use Stream::into_future I'm really trying to get the next value. It seems like next may be a better name?
I'll chime in as liking this as well.
I generally wouldn't expect next to move self. I'm used to the convention established in the Iterator trait of having next take &mut self.
Agree with @cramertj . next is a mutator method, and having Stream::next consume it is unexpected. I wouldn't be opposed to _introducing_ next(&mut self) -> Future<T> but I'm not sure how much utility such a method would have.
If you want to rename into_future, I think slice::split_first is its closest analogue in the standard library, so calling it split_first seems natural.
It's a bit off-topic but I couldn't find an answer how to take one item out of a stream without consuming the stream. So I'm looking exactly for a method like next(&mut self) -> Future<T>!
How can I achieve that at the moment?
Here is my original question:
https://www.reddit.com/r/rust/comments/6v11os/hey_rustaceans_got_an_easy_question_ask_here/dm4c85h/
@flosse that's unfortunately not easily done right now, but you can always write your own combinator to achieve what you're thinking of
We should consider this now that we have poll_next -- it's a common thing to have poll_foo and foo variants, where the latter yields a future.
@cramertj thoughts?
@aturon Yup, I think next makes sense.
Most helpful comment
I generally wouldn't expect
nextto moveself. I'm used to the convention established in theIteratortrait of havingnexttake&mut self.