[][src]Attribute Macro tokio::main

#[main]
This is supported on feature="rt-threaded" and feature="macros" only.

Marks async function to be executed by selected runtime.

Options:

  • core_threads=n - Sets core threads to n (requires rt-threaded feature).
  • max_threads=n - Sets max threads to n (requires rt-core or rt-threaded feature).

Function arguments:

Arguments are allowed for any functions aside from main which is special

Usage

Using default

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

Set number of core threads

#[tokio::main(core_threads = 1)]
async fn main() {
    println!("Hello world");
}