Skip to content

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) from poll_next), calling its poll_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.