1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use futures::Future;
use std::pin::Pin;

pub struct FuturesHandler {
    func: Pin<Box<dyn Future<Output = ()> + Send + Sync + 'static>>,
}

impl FuturesHandler {
    pub async fn new(f: impl Future<Output = ()> + Send + Sync + 'static) -> FuturesHandler {
        FuturesHandler { func: Box::pin(f) }
    }

    pub async fn run(&mut self) {
        self.func.as_mut().await;
    }
}