mirror of
https://github.com/async-rs/async-std.git
synced 2025-04-30 12:11:26 +00:00
* Cleanup: replace cfg-if with our macros * Prefix macros with cfg_ * Remove #[macro_export] from internal macros
23 lines
867 B
Rust
23 lines
867 B
Rust
use crate::future::Future;
|
|
use crate::stream::Stream;
|
|
|
|
/// Trait to represent types that can be created by summing up a stream.
|
|
///
|
|
/// This trait is used to implement the [`sum`] method on streams. Types which
|
|
/// implement the trait can be generated by the [`sum`] method. Like
|
|
/// [`FromStream`] this trait should rarely be called directly and instead
|
|
/// interacted with through [`Stream::sum`].
|
|
///
|
|
/// [`sum`]: trait.Sum.html#tymethod.sum
|
|
/// [`FromStream`]: trait.FromStream.html
|
|
/// [`Stream::sum`]: trait.Stream.html#method.sum
|
|
#[cfg(feature = "unstable")]
|
|
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
|
pub trait Sum<A = Self>: Sized {
|
|
/// Method which takes a stream and generates `Self` from the elements by
|
|
/// "summing up" the items.
|
|
fn sum<S, F>(stream: S) -> F
|
|
where
|
|
S: Stream<Item = A>,
|
|
F: Future<Output = Self>;
|
|
}
|