Rust 安装
安装
-
打开 www.rust-lang.org 网站,点击 Install
-
Linux 和 Mac
curl https://sh.rustup.rs -sSf | sh
-
Windows:按官网指示操作
-
Windows Subsystem for Linux
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
Current installation options:
default host triple: x86_64-apple-darwin
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
info: profile set to 'default'
info: default host triple is x86_64-apple-darwin
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: latest update on 2021-05-10, rust version 1.52.1 (9bc8c42bb 2021-05-09)
info: downloading component 'cargo'
4.3 MiB / 4.3 MiB (100 %) 3.0 MiB/s in 1s ETA: 0s
info: downloading component 'clippy'
info: downloading component 'rust-docs'
15.3 MiB / 15.3 MiB (100 %) 3.2 MiB/s in 4s ETA: 0s
info: downloading component 'rust-std'
23.0 MiB / 23.0 MiB (100 %) 2.5 MiB/s in 8s ETA: 0s
info: downloading component 'rustc'
58.6 MiB / 58.6 MiB (100 %) 2.8 MiB/s in 22s ETA: 0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
15.3 MiB / 15.3 MiB (100 %) 3.5 MiB/s in 4s ETA: 0s
info: installing component 'rust-std'
23.0 MiB / 23.0 MiB (100 %) 7.7 MiB/s in 7s ETA: 0s
info: installing component 'rustc'
58.6 MiB / 58.6 MiB (100 %) 9.9 MiB/s in 5s ETA: 0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-apple-darwin'
stable-x86_64-apple-darwin installed - rustc 1.52.1 (9bc8c42bb 2021-05-09)
Rust is installed now. Great!
To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, run:
source $HOME/.cargo/env
检查是否安装成功
$ rustc --version
rustc 1.52.1 (9bc8c42bb 2021-05-09)
会显示最新稳定版的版本号、commit hash 和 commit 日期
更新和卸载
-
更新 Rust
rustup update
-
卸载 Rust
rustup self uninstall
本地文档
安装 Rust 时会在本地安装文档,可离线浏览
运行下面命令可在浏览器打开本地文档
rustup doc
开发工具
- Visual Studio Code
- Rust 插件
- Clion(Intellij Idea 系列)
- Rust 插件