#!/usr/bin/env bash set -euo pipefail echo "==> Setting up Rust..." if command -v rustup &>/dev/null; then echo " rustup already installed, updating..." rustup update stable else echo " installing rustup..." curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path source "$HOME/.cargo/env" fi rustup toolchain install stable rustup component add clippy rustfmt rust-analyzer echo "==> Installing cargo tools..." CARGO_TOOLS=( cargo-watch # watch for changes and re-run cargo-expand # expand macros cargo-nextest # faster test runner cargo-flamegraph # CPU profiling / flamegraphs cargo-deny # lint deps (licenses, duplicates, advisories) cargo-mutants # mutation testing cargo-audit # check deps for known vulnerabilities ) for tool in "${CARGO_TOOLS[@]}"; do if cargo install --list | grep -q "^${tool} "; then echo " $tool already installed, skipping" else cargo install "$tool" fi done echo "==> Rust done."