SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use futures::Future; //0.1.28
  2.  
  3. type AnError = Box<std::error::Error>;
  4.  
  5. pub trait Test {
  6.     fn do_something(&self) -> Result<(), AnError>;
  7.    
  8.     fn create_future(&self) -> Box<Future<Item = (), Error = AnError>>;
  9.    
  10.     fn chain<'a>(&'a self) -> Box<Future<Item = (), Error = AnError> + 'a> {
  11.         Box::new(
  12.             self.create_future()
  13.                 .then(move |f| f.and_then(move |_| self.do_something())),
  14.         )
  15.     }
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top