Hacker News new | past | comments | ask | show | jobs | submit login

Are they always invoked explicitly? Or is it sometimes implicit?



The closest to implicit you can get is the `#[tokio::main]` attribute macro [1], which expands to something like this

    fn main() {
        tokio::runtime::Builder::new_multi_thread()
            .enable_all()
            .build()
            .unwrap()
            .block_on(async {
                println!("Hello world");
            })
    }
[1]: https://docs.rs/tokio/latest/tokio/attr.main.html#using-the-...


That's technically something the runtime implementation can choose, but for Tokio, the most common runtime, the sibling comment is correct that the only way to avoid having to explicitly define it is to use an annotation on the main function (which just generates the call to instantiate the runtime via a macro).


That's technically something the runtime implementation can choose, but for the most common runtime, Tokio,




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: