Features
Once enabled in an nmk project, the nmk-rust plugin provides the following features.
Check for cargo install
The nmk-rust plugin contributes instructions so that the sys.deps task checks and tells how to install cargo.
VSCode support
If the nmk-vscode plugin is also enabled in the project, following features are provided by nmk-rust.
VSCode extensions
Following extensions are recommended for rust development:
rust-analyzer – generic rust support
Even Better TOML – toml files support
Files generation
As part of the project setup, following files will be generated by nmk-rust.
Cargo configuration file
The cargo configuration file is generated by the rust.config task.
In addition to files and items that can be contributed by the project, nmk-rust generates the following items by default:
build.target-dir: set to ${rustTargetFolder}
(by convention allnmkprojects should generate their files in ${outputDir})
Manifest file
The cargo manifest file is generated by the rust.manifest task.
In addition to files and items that can be contributed by the project, nmk-rust generates the following items by default:
package.name: set to ${rustPackage}
package.edition: set to ${rustEdition}
package.authors: set to [”${projectAuthor}”]
Rustfmt configuration file
The rustfmt configuration file is generated by the rust.fmtcfg task.
In addition to files and items that can be contributed by the project, nmk-rust generates the following items by default:
max_width: set to ${rustLineLength}
(by convention allnmkprojects source code files should allow 160 characters wide lines)
Code format
As part of the project build, nmk-rust will call cargo fmt command to format rust source code (this is handled by the rust.format task).
If all project developers use VSCode IDE, this task shouldn’t do anything since the code is already formatted by the rust-analyzer extension.
However, this allows to make sure that the project code is always correctly formatted. Particularly in CI, if some code is committed without the correct format, this will cause the git.dirty task to fail the build.