File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,22 @@ use futures_core::stream::{FusedStream, Stream};
5
5
#[ cfg( feature = "sink" ) ]
6
6
use futures_sink:: Sink ;
7
7
8
- /// Combines two different futures, streams, or sinks having the same associated types into a single
9
- /// type.
8
+ /// Combines two different futures, streams, or sinks having the same associated types into a single type.
9
+ ///
10
+ /// This is useful when conditionally choosing between two distinct future types:
11
+ ///
12
+ /// ```rust
13
+ /// # use futures::future::{Either, Future};
14
+ /// let cond = true;
15
+ ///
16
+ /// let fut = if cond {
17
+ /// Either::Left(async move { 12 })
18
+ /// } else {
19
+ /// Either::Right(async move { 44 })
20
+ /// };
21
+ ///
22
+ /// assert_eq!(fut.await, 12);
23
+ /// ```
10
24
#[ derive( Debug , Clone ) ]
11
25
pub enum Either < A , B > {
12
26
/// First branch of the type
You can’t perform that action at this time.
0 commit comments