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: Sized { /// Method which takes a stream and generates `Self` from the elements by /// "summing up" the items. fn sum(stream: S) -> F where S: Stream, F: Future; }