Ubuntu上可以通过执行下面代码安装rust。
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
国内可能无法正常下载,这时候可以通过配置系统环境变量设置rust下载镜像
# 用于更新 toolchain
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
# 用于更新 rustup
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
再重新执行安装代码,如果一切正常,最后能看到如下提示
stable installed - rustc 1.48.0 (7eac88abb 2020-11-16)
Rust is installed now. Great!
To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done
automatically.
To configure your current shell run source $HOME/.cargo/env
更新rust
rustup update
Hello World
cargo new hello_cargo
build
cargo build
cargo build --release
执行
❯ .