From 0c8db16a67d02127cb6b4a1f399db054517f6aee Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Fri, 13 Nov 2020 18:24:26 +0100 Subject: Add `core::stream::Stream` This patch adds the `core::stream` submodule and implements `core::stream::Stream` in accordance with RFC2996. Add feedback from @camelid --- library/alloc/src/boxed.rs | 14 ++++++++++++++ library/alloc/src/lib.rs | 1 + 2 files changed, 15 insertions(+) (limited to 'library/alloc') diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 0aa52b35ced..e586ff89902 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -149,6 +149,7 @@ use core::ops::{ }; use core::pin::Pin; use core::ptr::{self, Unique}; +use core::stream::Stream; use core::task::{Context, Poll}; use crate::alloc::{handle_alloc_error, AllocError, Allocator, Global, Layout, WriteCloneIntoRaw}; @@ -1618,3 +1619,16 @@ where F::poll(Pin::new(&mut *self), cx) } } + +#[unstable(feature = "async_stream", issue = "79024")] +impl Stream for Box { + type Item = S::Item; + + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + Pin::new(&mut **self).poll_next(cx) + } + + fn size_hint(&self) -> (usize, Option) { + (**self).size_hint() + } +} diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 8d721ed7487..e524eb05fcd 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -82,6 +82,7 @@ #![feature(array_windows)] #![feature(allow_internal_unstable)] #![feature(arbitrary_self_types)] +#![feature(async_stream)] #![feature(box_patterns)] #![feature(box_syntax)] #![feature(cfg_sanitize)] -- cgit 1.4.1-3-g733a5