PeekableStream
and UnobtrusivePeekableStream
should document the behaviour after a poll returns Ready(None)
For example a StreamUnobtrusivePeeker
works by polling a stream and buffering a value from the stream so that it can be peeked. But futures::Stream
says:
Once a stream has finished (returned
Ready(None)
frompoll_next
), calling itspoll_next
method again may panic, block forever, or cause other kinds of problems.
Since StreamUnobtrusivePeeker
calls poll_next
, this means that PeekableStream::poll_peek
, unobtrusive_peek_mut
, the future returned from peek
, etc may panic if poll_peek
, poll_next
, etc have previously returned Ready(None)
. But this is not documented.
Alternatively, maybe it would be better if PeekableStream
and UnobtrusivePeekableStream
required FusedStream
instead of Stream
.