@@ -3,7 +3,7 @@ use core::pin::Pin;
3
3
use futures_core:: stream:: { FusedStream , Stream } ;
4
4
use futures_core:: task:: { Context , Poll } ;
5
5
6
- /// Stream for the [`select`](super::StreamExt::select) method .
6
+ /// Stream for the [`select`](super::StreamExt::select) function .
7
7
#[ derive( Debug ) ]
8
8
#[ must_use = "streams do nothing unless polled" ]
9
9
pub struct Select < St1 , St2 > {
@@ -14,16 +14,24 @@ pub struct Select<St1, St2> {
14
14
15
15
impl < St1 : Unpin , St2 : Unpin > Unpin for Select < St1 , St2 > { }
16
16
17
- impl < St1 , St2 > Select < St1 , St2 >
17
+ /// This function will attempt to pull items from both streams. Each
18
+ /// stream will be polled in a round-robin fashion, and whenever a stream is
19
+ /// ready to yield an item that item is yielded.
20
+ ///
21
+ /// After one of the two input stream completes, the remaining one will be
22
+ /// polled exclusively. The returned stream completes when both input
23
+ /// streams have completed.
24
+ ///
25
+ /// Note that this function consumes both streams and returns a wrapped
26
+ /// version of them.
27
+ pub fn select < St1 , St2 > ( stream1 : St1 , stream2 : St2 ) -> Select < St1 , St2 >
18
28
where St1 : Stream ,
19
29
St2 : Stream < Item = St1 :: Item >
20
30
{
21
- pub ( super ) fn new ( stream1 : St1 , stream2 : St2 ) -> Select < St1 , St2 > {
22
- Select {
23
- stream1 : stream1. fuse ( ) ,
24
- stream2 : stream2. fuse ( ) ,
25
- flag : false ,
26
- }
31
+ Select {
32
+ stream1 : stream1. fuse ( ) ,
33
+ stream2 : stream2. fuse ( ) ,
34
+ flag : false ,
27
35
}
28
36
}
29
37
0 commit comments