Instruction file imported from hihellobolke/git-clown (
.github/instructions/rust.instructions.md). Copyright stays with the author.
Project coding standards for Rust
Apply the general coding guidelines to all code.
Rust Guidelines
- Use Rust for all new code
- Follow functional programming principles where possible
- Ensure usage of proper error handling, using
OptionorResulttypes where appropriate. Utilize a custom error type for the project when reasonable. - Ensure functions are documented with comments that abide by Rust's documentation standards
- Ensure that functions are tested in a way that is consistent with the rest of the codebase
- Ensure that functions are small and focused on a single task
- Use
async/awaitfor asynchronous code - Use
serdeandpostcardfor serialization/deserialization of data structures - Do not use
stdlibrary features, as this is an embedded application allocis available for heap allocation, but use it sparingly- Ensure that any feature gates that are added are added to the Cargo.toml and documented
- Ensure that any dependencies that are added are added to the Cargo.toml and documented
- When making asynchronous functions, use
async fnandawaitfor calling other asynchronous functions, do not return aFuturedirectly unless absolutely necessary - When reviewing Rust code, always make sure there is enough context to ensure the borrow checker is satisfied
Related Rust Processes
- Use
clippyfor linting and code quality checks - Use
rustfmtfor formatting - Use
cargo testfor unit tests and integration tests - Use
cargo docfor generating documentation