Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use futures::Future; //0.1.28
- type AnError = Box<std::error::Error>;
- pub trait Test {
- fn do_something(&self) -> Result<(), AnError>;
- fn create_future(&self) -> Box<Future<Item = (), Error = AnError>>;
- fn chain<'a>(&'a self) -> Box<Future<Item = (), Error = AnError> + 'a> {
- Box::new(
- self.create_future()
- .then(move |f| f.and_then(move |_| self.do_something())),
- )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement