Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement