Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(async_await)]
- use std::boxed::Box;
- use std::future::Future;
- use std::pin::Pin;
- pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
- pub trait Queue<'a> {
- type ResultFut: Future<Output = ()> + 'a;
- fn store(&'a mut self, a: &'a str) -> Self::ResultFut;
- }
- struct MyQueue {
- }
- impl<'a> Queue<'a> for MyQueue {
- type ResultFut = BoxFuture<'a, ()>;
- fn store(&'a mut self, a: &'a str) -> Self::ResultFut {
- Box::pin(async {
- println!("A is {}", a);
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement