diff options
author | Taiki Endo <te316e89@gmail.com> | 2020-10-06 02:32:11 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-05 10:32:11 -0700 |
commit | c23c1ecbcbd7ff8e1ee137f691eddad31aa39331 (patch) | |
tree | 75796657a11bbe4f71152383e8d1103cdc1c2386 /tokio/src/stream/collect.rs | |
parent | 561a71ad63e5e9fde7900c700596952372e4c5ac (diff) |
io, stream: make ext trait futures !Unpin (#2910)
Make these future `!Unpin` for compatibility with async trait methods.
Diffstat (limited to 'tokio/src/stream/collect.rs')
-rw-r--r-- | tokio/src/stream/collect.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tokio/src/stream/collect.rs b/tokio/src/stream/collect.rs index a2b5169f..3f91a6f2 100644 --- a/tokio/src/stream/collect.rs +++ b/tokio/src/stream/collect.rs @@ -2,6 +2,7 @@ use crate::stream::Stream; use bytes::{Buf, BufMut, Bytes, BytesMut}; use core::future::Future; +use core::marker::PhantomPinned; use core::mem; use core::pin::Pin; use core::task::{Context, Poll}; @@ -10,7 +11,7 @@ use pin_project_lite::pin_project; // Do not export this struct until `FromStream` can be unsealed. pin_project! { /// Future returned by the [`collect`](super::StreamExt::collect) method. - #[must_use = "streams do nothing unless polled"] + #[must_use = "futures do nothing unless you `.await` or poll them"] #[derive(Debug)] pub struct Collect<T, U> where @@ -20,6 +21,9 @@ pin_project! { #[pin] stream: T, collection: U::InternalCollection, + // Make this future `!Unpin` for compatibility with async trait methods. + #[pin] + _pin: PhantomPinned, } } @@ -44,7 +48,11 @@ where let (lower, upper) = stream.size_hint(); let collection = U::initialize(sealed::Internal, lower, upper); - Collect { stream, collection } + Collect { + stream, + collection, + _pin: PhantomPinned, + } } } |