Attribute Macro main

Source
#[main]
Expand description

Enables an async main function.

§Examples

§Single-Threaded

By default, this spawns the single thread executor.

#[smol_potat::main]
async fn main() -> std::io::Result<()> {
    Ok(())
}

§Automatic Threadpool

Alternatively, smol_potat::main can used to automatically set the number of threads by adding the auto feature (off by default).

#[smol_potat::main] // with 'auto' feature enabled
async fn main() -> std::io::Result<()> {
    Ok(())
}

§Manually Configure Threads

To manually set the number of threads, add this to the attribute:

#[smol_potat::main(threads=3)]
async fn main() -> std::io::Result<()> {
    Ok(())
}
OSZAR »