Advertisement
Guest User

Untitled

a guest
May 24th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #![feature(async_await)]
  2.  
  3. use std::boxed::Box;
  4. use std::future::Future;
  5. use std::pin::Pin;
  6.  
  7. pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
  8.  
  9. pub trait Queue<'a> {
  10. type ResultFut: Future<Output = ()> + 'a;
  11.  
  12. fn store(&'a mut self, a: &'a str) -> Self::ResultFut;
  13. }
  14.  
  15. struct MyQueue {
  16. }
  17.  
  18. impl<'a> Queue<'a> for MyQueue {
  19. type ResultFut = BoxFuture<'a, ()>;
  20.  
  21. fn store(&'a mut self, a: &'a str) -> Self::ResultFut {
  22. Box::pin(async {
  23. println!("A is {}", a);
  24. })
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement