Skip to content

Instantly share code, notes, and snippets.

@dollarkillerx
Created January 20, 2021 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dollarkillerx/438472a3007faafe82aaadccb3624aac to your computer and use it in GitHub Desktop.
Save dollarkillerx/438472a3007faafe82aaadccb3624aac to your computer and use it in GitHub Desktop.
struct DynFn
{
    funcs: Vec<std::pin::Pin<Box<dyn std::future::Future<Output=()>>>>
}

impl DynFn
{
    fn new() -> DynFn {
        DynFn {
            funcs: Vec::new()
        }
    }
}


#[async_std::main]
async fn main() {
    println!("Hello, world!");

    let mut v=DynFn::new();
    v.funcs.push(Box::pin(  async  { println!("ok1");    }  ));
    v.funcs.push(Box::pin(  async  { println!("ok2");    }  ));
    for item in v.funcs{
        item.await
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment