3 Rust tooling

 

This chapter covers

  • Introducing core Rust language tools: rust-analyzer, rustfmt, Clippy, and sccache
  • Integrating Rust tools with Visual Studio Code
  • Using stable versus nightly toolchains
  • Exploring additional tools you may find useful

Mastery of any language depends on mastering its tooling. In this chapter, we’ll explore some of the critical tools you need to be effective with Rust.

Rust offers several tools to improve productivity and reduce the amount of busy work required to produce high-quality software. Rust’s compiler, rustc, is built upon LLVM, so Rust inherits the rich tools included with LLVM, such as LLVM’s debugger, LLDB. In addition to the tools you would expect to find from other languages, Rust includes a number of its own Rust-specific tools, which are discussed in this chapter.

The main tools discussed in this chapter are rust-analyzer, rustfmt, Clippy, and sccache. These are tools you’ll likely use every time you work with Rust. Additionally, I have included instructions for a few other tools, which you may find yourself using occasionally: cargo-update, cargo-expand, cargo-fuzz, cargo-watch, and cargo-tree.

3.1 Overview of Rust tooling

3.2 Using rust-analyzer for Rust IDE integration

3.2.1 Magic completions

3.3 Using rustfmt to keep code tidy

3.3.1 Installing rustfmt

3.3.2 Configuring rustfmt

3.4 Using Clippy to improve code quality

3.4.1 Installing Clippy

3.4.2 Clippy’s lints

3.4.3 Configuring Clippy

3.4.4 Automatically applying Clippy’s suggestions

3.4.5 Using Clippy in CI/CD

3.5 Reducing compile times with sccache

3.5.1 Installing sccache

sitemap