Linux 下 Rust 环境配置指南
一 安装 Rust 工具链
curl --proto 'https' --tlsv1.2 -sSf https://sh.rustup.rs | shsource "$HOME/.cargo/env" 使环境变量生效rustc --versioncargo --version二 配置环境变量与 Shell
export PATH="$HOME/.cargo/bin:$PATH"source ~/.bashrc 或 source ~/.zshrcwhich rustc、which cargo 应指向 ~/.cargo/bin。三 国内网络加速(可选)
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustupexport RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
四 创建并运行第一个项目
cargo new hello-rust && cd hello-rustcargo runHello, world!cargo buildcargo runcargo testcargo build --release五 编辑器与常用工具
cargo install rustfmtcargo install clippyrustup component add rust-src)。