async-std/src/stream/from_stream.rs
Yoshua Wuyts e6a3160c8b
add unstable cfg to FromStream/IntoStream
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2019-09-17 19:17:51 +02:00

29 lines
809 B
Rust

use super::IntoStream;
use std::pin::Pin;
/// Conversion from a `Stream`.
///
/// By implementing `FromStream` for a type, you define how it will be created from a stream.
/// This is common for types which describe a collection of some kind.
///
/// See also: [`IntoStream`].
///
/// [`IntoStream`]: trait.IntoStream.html
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub trait FromStream<T: Send> {
/// Creates a value from a stream.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// // use async_std::stream::FromStream;
///
/// // let _five_fives = async_std::stream::repeat(5).take(5);
/// ```
fn from_stream<'a, S: IntoStream<Item = T> + Send + 'a>(
stream: S,
) -> Pin<Box<dyn core::future::Future<Output = Self> + Send + 'a>>;
}