User-defined Playground

Rust Programming Playground

A disposable Rust development environment with stable, beta, and nightly toolchains, bacon, cargo-nextest, rustfmt, clippy, rust-analyzer, and the musl target pre-installed.

Startup configuration
rust-01
Rust Programming playground: A disposable Rust development environment with stable, beta, and nightly toolchains, bacon, cargo-nextest, rustfmt, clippy, rust-analyzer, and the musl target pre-installed.

A disposable Rust development environment. Stable 1.98.1, beta, and nightly toolchains, rustfmt, clippy, rust-analyzer, codelldb, and the musl cross-compilation target are all pre-installed. Full IDE support via VS Code with a native debugger. Runs on 4 vCPU / 10 GiB RAM / 100 GiB disk.

Nothing is persisted once the playground stops.

What's included

  • rustc / cargo (stable 1.98.1 as default, beta, nightly)
  • rustfmt code formatter and clippy linter (all three toolchains)
  • rust-src so rust-analyzer can resolve the standard library
  • bacon: background check, lint and test runner
  • cargo-nextest: faster test runner with clearer output
  • cargo-expand: shows code after macro expansion
  • cargo-audit: scans dependencies for known vulnerabilities
  • cargo-binstall: installs prebuilt cargo tools in seconds
  • cargo-watch: kept for older lessons, bacon replaces it
  • rust-analyzer for IDE intelligence in VS Code, with clippy on save
  • codelldb native debugger in VS Code
  • x86_64-unknown-linux-musl target for static binaries
  • A C toolchain, pkg-config, and libssl-dev for the common -sys crates
  • zsh with a Catppuccin starship prompt that shows the full path, git branch, Rust version and crate version, plus autosuggestions, syntax highlighting and atuin history search
  • lazygit, bat, eza, fd, ripgrep, zoxide, delta

Key commands

New project

cargo new hello && cd hello
cargo run

Build

cargo check                 # type check, no linking, fastest
cargo build                 # debug build
cargo build --release       # optimized build

# Static binary, runs anywhere, no libc needed
cargo build --release --target x86_64-unknown-linux-musl

Test

cargo test                  # run all tests
cargo test test_name        # run one test
cargo test -- --nocapture   # show println! output
cargo nextest run           # faster runner, one line per test

Format and lint

cargo fmt                   # format all files
cargo fmt -- --check        # check without modifying
cargo clippy                # lint with suggestions
cargo clippy -- -D warnings # treat warnings as errors

Watch mode

bacon                       # recheck on every save
bacon clippy                # relint on every save
bacon test                  # retest on every save
bacon run                   # rerun on every save

Dependencies

cargo add serde --features derive
cargo update                # update the lockfile
cargo tree                  # show the dependency graph
cargo audit                 # check for known vulnerabilities
cargo doc --open            # build and read your crate docs

Inspect macros

cargo expand                # full crate after macro expansion
cargo expand main           # one module or item

Switch toolchain

cargo +nightly run          # run with nightly
cargo +beta build           # build with beta
rustup show                 # what is installed and active
rustup toolchain list       # all toolchains

Understand an error

rustc --explain E0382       # full write-up for any error code

Terminal shortcuts

cb / cr / ct                # cargo build / run / test
cn / cl / cf                # cargo nextest run / clippy / fmt
ll                          # detailed file listing
z hello                     # jump to a recent directory
lg                          # lazygit
icons on                    # Nerd Font icons, if your own terminal has the font

Ctrl+R searches history, Ctrl+T picks a file, Alt+C jumps into a subdirectory.

Where things live

The toolchain is installed system wide, so root and laborant share it.

PathContents
/usr/local/rustupToolchains and components
/usr/local/cargoCargo binaries and the crates.io cache

Both are writable by any user, so cargo install and cargo add work without sudo.

Every playground includes
Learn more about playgrounds
Start
Settings