@@ -3,7 +3,7 @@ use core::pin::Pin;
33use futures_core:: stream:: { FusedStream , Stream } ;
44use futures_core:: task:: { Context , Poll } ;
55
6- /// Stream for the [`select`](super::StreamExt::select) method .
6+ /// Stream for the [`select`] function .
77#[ derive( Debug ) ]
88#[ must_use = "streams do nothing unless polled" ]
99pub struct Select < St1 , St2 > {
@@ -14,16 +14,24 @@ pub struct Select<St1, St2> {
1414
1515impl < St1 : Unpin , St2 : Unpin > Unpin for Select < St1 , St2 > { }
1616
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 >
1828 where St1 : Stream ,
1929 St2 : Stream < Item = St1 :: Item >
2030{
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 ,
2735 }
2836
2937 /// Acquires a reference to the underlying streams that this combinator is
0 commit comments