📚Cheatsheets

Cheatsheet collection for go, rust, python, shell and javascript.

Setup Tokio Async in Main function

Manual

fn main() {
    let rt = tokio::runtime::Builder::new_current_thread()
        .build()
        .unwrap();
    let fut = MyFuture {};
    rt.block_on(fut);
}

With macro

#[tokio::main(flavor = "current_thread")]
async fn main() {
    let fut = MyFuture {};
    fut.await
}