[][src]Attribute Macro smol_potat::main

#[main]

Enables an async main function.

Examples

Dynamic threads

By default, this spawns as many threads as is in the SMOL_THREADS environment variable, or 1 if it is not specified.

This example is not tested
#[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).

This example is not tested
#[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:

This example is not tested
#[smol_potat::main(threads=3)]
async fn main() -> std::io::Result<()> {
    Ok(())
}

Set the crate root

By default smol-potat will use ::smol_potat as its crate root, but you can override this with the crate option:

This example is not tested
use smol_potat as other_smol_potat;

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