1 unstable release

0.36.0 Oct 18, 2025

#24 in #native-applications

Download history 153/week @ 2026-01-18 287/week @ 2026-01-25 515/week @ 2026-02-01 514/week @ 2026-02-08 901/week @ 2026-02-15 578/week @ 2026-02-22 797/week @ 2026-03-01 1066/week @ 2026-03-08 808/week @ 2026-03-15 820/week @ 2026-03-22 768/week @ 2026-03-29 819/week @ 2026-04-05 650/week @ 2026-04-12 847/week @ 2026-04-19 1111/week @ 2026-04-26 814/week @ 2026-05-03

3,447 downloads per month
Used in 12 crates (via kiss3d)

BSD-3-Clause

6KB
50 lines

kiss3d-macro

Procedural macros for the kiss3d crate.

The #[kiss3d::main] macro

This macro simplifies writing cross-platform kiss3d applications that work on both native platforms and WebAssembly.

Benefits

  • No additional dependencies: You don't need to add pollster or wasm_bindgen_futures to your Cargo.toml - they're automatically available through kiss3d
  • Cleaner code: Eliminates platform-specific boilerplate
  • Less error-prone: No need to manually maintain dual entry points

Problem

When writing kiss3d applications that target both native and WASM, you previously had to write boilerplate code like this:

#[cfg(not(target_arch = "wasm32"))]
fn main() {
    pollster::block_on(run())
}

#[cfg(target_arch = "wasm32")]
fn main() {
    wasm_bindgen_futures::spawn_local(run())
}

async fn run() {
    let mut window = Window::new("My App");
    while window.render_async().await {
        // Your render loop
    }
}

Solution

With the #[kiss3d::main] macro, you can simplify this to:

#[kiss3d::main]
async fn main() {
    let mut window = Window::new("My App");
    while window.render_async().await {
        // Your render loop
    }
}

The macro automatically generates the appropriate platform-specific entry points:

  • On native platforms: uses pollster::block_on to run the async function
  • On WASM: uses wasm_bindgen_futures::spawn_local to spawn the async function

Requirements

  • The function must be named main
  • The function must be async
  • The function cannot have parameters
  • The function should use the async rendering methods (render_async(), render_with_camera_async(), etc.)

Example

See examples/instancing3d.rs and examples/macro_test.rs for complete examples.

Dependencies

~91–435KB
~10K SLoC