Est. read time: 3 minutes | Last updated: February 23, 2024 by John Gentile


Contents

Install and Tools

  • Installing Rust is fairly simple using the rustup script: $ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
    • On macOS, make sure C compiler is installed with $ xcode-select --install
  • Rust can be updated at any time with $ rustup update

Compilation

  • If using a Cargo project, $ cargo build can be used
    • $ cargo run can be used to build and then execute in one command.
  • Or for a more straight forward approach, $ rustc main.rs compiles the Rust file main.rs into an executable file main.

Cargo

cargo is installed automatically with the typical install process.

  • A new Rust project can be created by running $ cargo new <project_name> and, by default, creates a variety of helpful files:
    • Creates a .gitignore file and -if not already within a git repo- initializes a new Git repo
    • A TOML config file Cargo.toml that describes the metadata and dependencies of the Rust project.
    • A src/ directory in which Rust source should live.

For more info, see The Cargo Book.

As part of cargo there’s also:

  • clippy: a collection of lints to catch common mistakes and improve Rust code
  • rustfmt: a Rust code formatter, can also be run with cargo fmt.

rustdoc

Rust ships with a tool called rustdoc which can generate documentation by parsing specially formatted comments in Rust source code.

rustdoc can also perform documentation tests within comments.

Cross-Compile & FFI

Other Tools

  • rust-analyzer: implements Language Server Protocol (LSP) for Rust (allows IDEs/editors to have completion, definition, goto, etc. features).
  • cargo-audit: audits dependencies for crates with known security vulnerabilities, maintained by RustSec Advisory Database.
  • grcov: collect & aggregate code coverage data for source files (also supports C/C++ projects, or files that can be processed by llvm/clang/gcc).
  • loom: concurrency permutation testing for parallel Rust code.
  • Miri: interpreter for Rust’s mid-level interpreter (MIR) and detect classes of undefined behavior.

Language

Async

See rust-async-framework for more details and implementation examples.

References

Low-Level / Embedded

Rust for Linux Kernel Development

References

NOTE: offline documentation is locally installed with rustup and can be opened in your browser by simply running rustup doc. For public/open-source crates, documentation is also often found in Docs.rs.

Rust Core Docs

  • The Standard Library: Comprehensive guide to the Rust standard library APIs.
  • Edition Guide: Guide to the Rust editions.
  • Cargo Book: A book on Rust’s package manager and build system.
  • Rustdoc Book: Learn how to make awesome documentation for your crate.
  • Rustc Book: Familiarize yourself with the knobs available in the Rust compiler.
  • Compiler Error Index: In-depth explanations of the errors you may see from the Rust compiler.

Application Domain Docs

To Read

Books

Repos