Make Once a DoubleEndedStream
@@ -4,6 +4,7 @@ use pin_project_lite::pin_project;
use crate::stream::Stream;
use crate::task::{Context, Poll};
+use crate::stream::double_ended_stream::DoubleEndedStream;
/// Creates a stream that yields a single item.
///
@@ -46,3 +47,9 @@ impl<T> Stream for Once<T> {
Poll::Ready(self.project().value.take())
}
}
+
+impl <T> DoubleEndedStream for Once<T> {
+ fn poll_next_back(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
+ Poll::Ready(self.project().value.take())
+ }
+}
