Skip to main content

main

Macro main 

Source
macro_rules! main {
    ($app:expr $(,)?) => { ... };
}
Expand description

Declares a frus application’s single entry point. Invoked exactly once (in the application’s library), it generates the entry point of every platform, all delegating to the same application:

  • desktop and iOS: a run() function, which the app’s thin binary calls;
  • Android: the native android_main symbol the activity expects;
  • web: the #[wasm_bindgen(start)] function.

The cfgs below are written with explicit target_os / target_arch predicates rather than the desktop / android / web aliases from build.rs: the body of a macro_rules! expands in the application’s crate, where those aliases are not defined. A #[cfg(desktop)] there would always be false, and the application would end up with no entry point at all.

The argument is an expression building the application (re-evaluated per platform, never shared):

ⓘ
frus_shell::main!(App::default());

The web platform keeps its own wasm-bindgen dependency (targeted at wasm32), which the generated #[wasm_bindgen(start)] entry point refers to via ::wasm_bindgen.