Linting and Formatting

There are two main canonical tool for formatting and linting Rust code. The first is cargo-fmt, the formatter. The second is clippy, the linter.

To run the formatter, just run cargo fmt. That's it.

To run the linter, run cargo clippy after installing it one time. Clippy is very helpful at suggesting idiomatic code, and it improves over time (read: it will sometimes come back and find things in code that you thought was fine last month). It's invaluable as both a Rust learner and as an experienced Rust programmer, and it's usually good practice to treat Clippy warnings as errors (with specific exceptions annotated in the code if merited).

There are various options to configure these tools. I suggest using them vanilla for a while, if not forever. It keeps things consistent across the Rust ecosystem, and the suggestions are usually there for a reason. But if you do want to configure things, you can dive in!