Guest User

Untitled

a guest
Jun 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. extern crate tokio_threadpool;
  2. extern crate futures;
  3.  
  4. use futures::Future;
  5. use futures::future::ok;
  6. use futures::future::Either;
  7. use futures::FutureExt;
  8.  
  9. fn a() -> impl Future<Item = Result<i32, u64>, Error = String> {
  10. ok(Ok(5))
  11. }
  12.  
  13. fn do_it(a: impl Future<Item = Result<i32, u64>, Error = String>) -> impl Future<Item = i32, Error = Either<u64, String>> {
  14. a.then(|res| match res {
  15. Ok(Ok(a)) => Ok(a),
  16. Ok(Err(b)) => Err(Either::Left(b)),
  17. Err(c) => Err(Either::Right(c))
  18. })
  19. }
  20.  
  21. fn main() {
  22.  
  23. }
Add Comment
Please, Sign In to add comment