use core::future::Future; use core::marker::PhantomPinned; use core::mem; use core::pin::Pin; use core::task::{Context, Poll}; 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 = "futures do nothing unless you `.await` or poll them"] #[derive(Debug)] pubstruct Collect<T, U> where
T: Stream,
U: FromStream<T::Item>,
{ #[pin]
stream: T,
collection: U::InternalCollection, // Make this future `!Unpin` for compatibility with async trait methods. #[pin]
_pin: PhantomPinned,
}
}
/// Convert from a [`Stream`](crate::Stream). /// /// This trait is not intended to be used directly. Instead, call /// [`StreamExt::collect()`](super::StreamExt::collect). /// /// # Implementing /// /// Currently, this trait may not be implemented by third parties. The trait is /// sealed in order to make changes in the future. Stabilization is pending /// enhancements to the Rust language. pubtrait FromStream<T>: sealed::FromStreamPriv<T> {}
impl<T, U> Collect<T, U> where
T: Stream,
U: FromStream<T::Item>,
{ pub(super) fn new(stream: T) -> Collect<T, U> { let (lower, upper) = stream.size_hint(); let collection = U::initialize(sealed::Internal, lower, upper);
impl<T, U, E> FromStream<Result<T, E>> for Result<U, E> where U: FromStream<T> {}
impl<T, U, E> sealed::FromStreamPriv<Result<T, E>> for Result<U, E> where
U: FromStream<T>,
{ type InternalCollection = Result<U::InternalCollection, E>;
pub(crate) mod sealed { #[doc(hidden)] pubtrait FromStreamPriv<T> { /// Intermediate type used during collection process /// /// The name of this type is internal and cannot be relied upon. type InternalCollection;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.