File tree Expand file tree Collapse file tree 4 files changed +53
-4
lines changed Expand file tree Collapse file tree 4 files changed +53
-4
lines changed Original file line number Diff line number Diff line change @@ -42,19 +42,23 @@ cfg_if! {
4242 if #[ cfg( any( feature = "unstable" , feature = "docs" ) ) ] {
4343 mod double_ended_stream;
4444 mod exact_size_stream;
45- mod fused_stream;
4645 mod extend;
4746 mod from_stream;
48- mod into_stream ;
47+ mod fused_stream ;
4948 mod interval;
49+ mod into_stream;
50+ mod product;
51+ mod sum;
5052
5153 pub use double_ended_stream:: DoubleEndedStream ;
5254 pub use exact_size_stream:: ExactSizeStream ;
5355 pub use extend:: Extend ;
5456 pub use from_stream:: FromStream ;
5557 pub use fused_stream:: FusedStream ;
56- pub use into_stream:: IntoStream ;
5758 pub use interval:: { interval, Interval } ;
59+ pub use into_stream:: IntoStream ;
60+ pub use product:: Product ;
61+ pub use sum:: Sum ;
5862
5963 pub use stream:: Merge ;
6064 }
Original file line number Diff line number Diff line change 1+ use crate :: future:: Future ;
2+ use crate :: stream:: Stream ;
3+
4+ /// Trait to represent types that can be created by productming up a stream.
5+ ///
6+ /// This trait is used to implement the [`product`] method on streams. Types which
7+ /// implement the trait can be generated by the [`product`] method. Like
8+ /// [`FromStream`] this trait should rarely be called directly and instead
9+ /// interacted with through [`Stream::product`].
10+ ///
11+ /// [`product`]: trait.Product.html#tymethod.product
12+ /// [`FromStream`]: trait.FromStream.html
13+ /// [`Stream::product`]: trait.Stream.html#method.product
14+ #[ cfg_attr( feature = "docs" , doc( cfg( unstable) ) ) ]
15+ #[ cfg( any( feature = "unstable" , feature = "docs" ) ) ]
16+ pub trait Product < A = Self > : Sized {
17+ /// Method which takes a stream and generates `Self` from the elements by
18+ /// multiplying the items.
19+ fn product < S , F > ( stream : S ) -> F
20+ where
21+ S : Stream < Item = A > ,
22+ F : Future < Output = Self > ;
23+ }
Original file line number Diff line number Diff line change 1+ use crate :: future:: Future ;
2+ use crate :: stream:: Stream ;
3+
4+ /// Trait to represent types that can be created by summing up a stream.
5+ ///
6+ /// This trait is used to implement the [`sum`] method on streams. Types which
7+ /// implement the trait can be generated by the [`sum`] method. Like
8+ /// [`FromStream`] this trait should rarely be called directly and instead
9+ /// interacted with through [`Stream::sum`].
10+ ///
11+ /// [`sum`]: trait.Sum.html#tymethod.sum
12+ /// [`FromStream`]: trait.FromStream.html
13+ /// [`Stream::sum`]: trait.Stream.html#method.sum
14+ #[ cfg_attr( feature = "docs" , doc( cfg( unstable) ) ) ]
15+ #[ cfg( any( feature = "unstable" , feature = "docs" ) ) ]
16+ pub trait Sum < A = Self > : Sized {
17+ /// Method which takes a stream and generates `Self` from the elements by
18+ /// "summing up" the items.
19+ fn sum < S , F > ( stream : S ) -> F
20+ where
21+ S : Stream < Item = A > ,
22+ F : Future < Output = Self > ;
23+ }
Original file line number Diff line number Diff line change 11//! A thread pool for running blocking functions asynchronously.
22
3- use std:: future:: Future ;
43use std:: sync:: atomic:: { AtomicU64 , Ordering } ;
54use std:: thread;
65use std:: time:: Duration ;
You can’t perform that action at this time.
0 commit comments