@@ -509,17 +509,49 @@ pub trait FutureExt: Future {
509509 /// assert_eq!(x, block_on(future).unwrap());
510510 /// # }
511511 /// ```
512+ #[ deprecated( note = "use `left_future` instead" ) ]
512513 fn left < B > ( self ) -> Either < Self , B >
513514 where B : Future < Item = Self :: Item , Error = Self :: Error > ,
514515 Self : Sized
515516 {
516517 Either :: Left ( self )
517518 }
518519
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+
519551 /// Wrap this future in an `Either` future, making it the right-hand variant
520552 /// of that `Either`.
521553 ///
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`
523555 /// statements that evaluate to different futures in different branches.
524556 ///
525557 /// # Examples
@@ -540,13 +572,45 @@ pub trait FutureExt: Future {
540572 /// assert_eq!(x, block_on(future).unwrap());
541573 /// # }
542574 /// ```
575+ #[ deprecated( note = "use `right_future` instead" ) ]
543576 fn right < A > ( self ) -> Either < A , Self >
544577 where A : Future < Item = Self :: Item , Error = Self :: Error > ,
545578 Self : Sized ,
546579 {
547580 Either :: Right ( self )
548581 }
549582
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+
550614 /// Convert this future into a single element stream.
551615 ///
552616 /// The returned stream contains single success if this future resolves to
0 commit comments