#run #macro #proc #proc-macro #rhachis

macro rhachis-run-macro

A proc macro for the Rhachis game library

5 unstable releases

0.3.1 Jan 31, 2023
0.3.0 Jan 24, 2023
0.2.0 Dec 17, 2022
0.1.1 Oct 1, 2022
0.1.0 Sep 22, 2022

#126 in #proc


Used in rhachis

MIT license

4KB
61 lines

The run macro is a shorthand for making a main function.

You use it by prefixing your Game implementing struct with #[rhachis::run]. The following code sample:

use rhachis::*;
use rhachis::graphics::EmptyRenderer;

#[rhachis::run]
struct Run(EmptyRenderer);

impl Game for Run {
    // ...
}

is evaluated to:

use rhachis::*;
use rhachis::graphics::EmptyRenderer;

fn main() {
    Run::run()
}

struct Run(EmptyRenderer);

impl Game for Run {
    // ...
}

The main function is very often the same in all Rhachis projects which is why this shorthand is available, but you can still implement the main function yourself.

Dependencies

~0–1.2MB
~21K SLoC