Guest User

Untitled

a guest
Aug 17th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #![feature(async_await, futures_api)]
  2.  
  3. use std::future::Future;
  4.  
  5. async fn func() -> Result<(), ()> {
  6. Ok(())
  7. }
  8.  
  9. trait MyTrait {
  10. type Future: Future;
  11. fn start(&mut self) -> Self::Future;
  12. }
  13.  
  14. impl<F: Future> MyTrait for fn() -> F {
  15. type Future = F;
  16. fn start(&mut self) -> Self::Future {
  17. (self)()
  18. }
  19. }
  20.  
  21. fn main() {
  22. //let f: () = func;
  23. use_my_trait(func)
  24. }
  25.  
  26. fn use_my_trait<T: MyTrait>(t: T) {}
Add Comment
Please, Sign In to add comment