Cargo
The cargo module shouldn't be too suprising, we use it to build rust projects. Technically in a rust only project, this might not have much value, cargo itself exists, why bother not just re-use that. The reasoning lies in when trying to have a project that does much more than just compile rust.
Rust as 'scripting'
When building projects, we are really running programs to produce files. Most developers could easily do this in their favorite language, like rust. The cargo module makes this easy, you could produce a binary crate, that reads args and writes files out. This could then be used to produce something more complicated, like a static html website, but you can manipulate your program in the repo itself, rather than requiring an external tool.
The cargo module shines here, as it's able to also know when the sources of the 'template' program changed, and thus will rebuild the templating program. Meaning up to date outputs.
Installation
Simply add to your dependencies
[dependencies]
ninja-files-cargo = "0.1.0"
Usage
This exposes a function ninja-files-cargo::build, which takes the Cargo.toml, and the target exe that will be built. This works even in workspaces (you just need to track where the file will be output in the workspace).
It also works for libraries, so can be a cheap way to 'build all' including rust libs, without remembering all the flags and commands