@@ -509,17 +509,49 @@ pub trait FutureExt: Future {
509
509
/// assert_eq!(x, block_on(future).unwrap());
510
510
/// # }
511
511
/// ```
512
+ #[ deprecated( note = "use `left_future` instead" ) ]
512
513
fn left < B > ( self ) -> Either < Self , B >
513
514
where B : Future < Item = Self :: Item , Error = Self :: Error > ,
514
515
Self : Sized
515
516
{
516
517
Either :: Left ( self )
517
518
}
518
519
520
+ /// Wrap this future in an `Either` future, making it the left-hand variant
521
+ /// of that `Either`.
522
+ ///
523
+ /// This can be used in combination with the `right_future` method to write `if`
524
+ /// statements that evaluate to different futures in different branches.
525
+ ///
526
+ /// # Examples
527
+ ///
528
+ /// ```
529
+ /// # extern crate futures;
530
+ /// use futures::executor::block_on;
531
+ /// use futures::future::*;
532
+ ///
533
+ /// # fn main() {
534
+ /// let x = 6;
535
+ /// let future = if x < 10 {
536
+ /// ok::<_, bool>(x).left_future()
537
+ /// } else {
538
+ /// empty().right_future()
539
+ /// };
540
+ ///
541
+ /// assert_eq!(x, block_on(future).unwrap());
542
+ /// # }
543
+ /// ```
544
+ fn left_future < B > ( self ) -> Either < Self , B >
545
+ where B : Future < Item = Self :: Item , Error = Self :: Error > ,
546
+ Self : Sized
547
+ {
548
+ Either :: Left ( self )
549
+ }
550
+
519
551
/// Wrap this future in an `Either` future, making it the right-hand variant
520
552
/// of that `Either`.
521
553
///
522
- /// This can be used in combination with the `left ` method to write `if`
554
+ /// This can be used in combination with the `left_future ` method to write `if`
523
555
/// statements that evaluate to different futures in different branches.
524
556
///
525
557
/// # Examples
@@ -540,13 +572,45 @@ pub trait FutureExt: Future {
540
572
/// assert_eq!(x, block_on(future).unwrap());
541
573
/// # }
542
574
/// ```
575
+ #[ deprecated( note = "use `right_future` instead" ) ]
543
576
fn right < A > ( self ) -> Either < A , Self >
544
577
where A : Future < Item = Self :: Item , Error = Self :: Error > ,
545
578
Self : Sized ,
546
579
{
547
580
Either :: Right ( self )
548
581
}
549
582
583
+ /// Wrap this future in an `Either` future, making it the right-hand variant
584
+ /// of that `Either`.
585
+ ///
586
+ /// This can be used in combination with the `left_future` method to write `if`
587
+ /// statements that evaluate to different futures in different branches.
588
+ ///
589
+ /// # Examples
590
+ ///
591
+ /// ```
592
+ /// # extern crate futures;
593
+ /// use futures::executor::block_on;
594
+ /// use futures::future::*;
595
+ ///
596
+ /// # fn main() {
597
+ /// let x = 6;
598
+ /// let future = if x < 10 {
599
+ /// ok::<_, bool>(x).left_future()
600
+ /// } else {
601
+ /// empty().right_future()
602
+ /// };
603
+ ///
604
+ /// assert_eq!(x, block_on(future).unwrap());
605
+ /// # }
606
+ /// ```
607
+ fn right_future < A > ( self ) -> Either < A , Self >
608
+ where A : Future < Item = Self :: Item , Error = Self :: Error > ,
609
+ Self : Sized ,
610
+ {
611
+ Either :: Right ( self )
612
+ }
613
+
550
614
/// Convert this future into a single element stream.
551
615
///
552
616
/// The returned stream contains single success if this future resolves to
0 commit comments