Rust

Tools

  • rustup: rust installer and update manager

  • rustc: rust compiler

  • cargo: rust build system and package manager

  • cargo clippy: rust code linter

  • cargo fmt: rust code formatter

Directories

  • ~/.rustup: rustup metadata and toolchains

  • ~/.cargo: cargo home directory

  • ~/.cargo/bin: rust commands directory

Configuration

Add rust tools bin directory to shell path

~/.cargo/bin

Help Docs

Open local rust docs

Rust Compiler

Compile rust file

Run compiled file

Rustup

Show current configured version and check for available updates

Update rust toolchains and rustup

Cargo

Show cargo version

Create new cargo project

Add dependency (then install dependency via cargo build)

Update cargo crate dependencies to latest semver minor release versions (major version bumps require editing cargo.toml)

Check package and dependencies for errors

Build project (--release or -r for release mode with build optimisations)

Execute generated binary to run debug or release build app

Build and run project (in single step)

Run tests and benchmarking

Document project (creates local docs for project and all dependencies)

Publish library to crates.io

VS Code

Extension: rust-analyzer

Format code: SHIFT + OPTION + F (can also be configured to format on save / paste)

Clippy

Run clippy (rust linter) on project

Automatically fix linter issues that have known resolutions

Last updated