Skip to main content

main

Attribute Macro main 

Source
#[main]
Expand description

Marks an async fn main as the program entry point.

Rewrites the annotated function into a synchronous main that builds an AsyncExecutor and blocks on the original body, preserving the function’s attributes and visibility.

The attribute takes no arguments and the executor is constructed with its defaults; a caller needing a configured executor should build one directly and call block_on instead.

§Panics

The generated main panics if the executor cannot be created. That is deliberate: it runs before any user code, so there is no state to unwind and nothing useful to recover to.