aural_isle/CONTRIBUTING.md

1.5 KiB

Contribution Guidelines

Code Formatting

We format all Rust code using edition 2021 rules. This edition is defined in our Cargo.toml and most methods below will pick this up automatically.

Manual Method

The most editor agnostic way to format your Rust code is by manually running cargo's fmt sub command.

To check if your code is formatted without making changes, run cargo fmt --check. Then if you want to format your code you can run just cargo fmt.

VScode

We recommend the meta extension Rust, which includes rust-analyzer. Then to set your editor to format on save:

  • In Visual Studio Code, press Control + Shift + P or Command + Shift + P (Mac) to open the command palette and type setting and then select Preferences: Open User Settings option.
  • Search for format on save setting and check the checkbox.

You can also set language specific settings as outlined here. You will again want to then search for format on save and check the checkbox.

Other Editors

You will first need to install rust-analyzer, then configure your editor and install any needed plugins or extensions as outlined on that page.

Pre Commit Hook

If you want to think about formatting your code less and just have git yell at you whe you try to commit code that is not properly formatted, you can use a simple pre-commit hook.

After cloning the repo, the file pre-commit-hook to .git/hooks/pre-commit. That's it.