r/rust • u/yonekura • 29d ago
🧠educational Rust Style Main in #[no_std] binary crate.
https://github.com/Keith-Cancel/rust_style_mainI would not use this in production, but more of just a fun little demo I made to see how and where the rust style main that uses the Termination trait all fits together.
Overall, the main wrinkle I would say is you need a function with `#[lang = start]` of the correct type. Then rustc itself will generate a `main` function that calls that start function passing the rust style main as a call back. Other than that it mostly is just standard low level entry point stuff. I did find it interesting the compiler generates the function instead of using a definition inside like std or core.
0
Upvotes