
Rust
V1
2022/01/27阅读:74主题:Pornhub黄
Rust 安装
Rust 安装
一.离线版本
1.下载
wget https://static.rust-lang.org/dist/rust-1.56.1-x86_64-unknown-linux-gnu.tar.gz
2.解压安装
tar -xvzf rust-1.56.1-x86_64-unknown-linux-gnu.tar.gz
sudo sh install.sh
3.设置代理并安装
export https_proxy=http://xxx.xxx.com:8080
rustup install stable
rustup default stable
二. 在线版本
# 用于更新 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
设置
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
设置国内镜像
[rusting@localhost ~]$ export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
[rusting@localhost ~]$ export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
[rusting@localhost ~]$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:
/home/rusting/.rustup
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory located at:
/home/rusting/.cargo
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
/home/rusting/.cargo/bin
This path will then be added to your PATH environment variable by
modifying the profile files located at:
/home/rusting/.profile
/home/rusting/.bash_profile
/home/rusting/.bashrc
You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
Current installation options:
default host triple: x86_64-unknown-linux-gnu
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-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2021-11-01, rust version 1.56.1 (59eed8a2a 2021-11-01)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
17.3 MiB / 17.3 MiB (100 %) 7.5 MiB/s in 2s ETA: 0s
info: downloading component 'rust-std'
23.5 MiB / 23.5 MiB (100 %) 8.0 MiB/s in 2s ETA: 0s
info: downloading component 'rustc'
52.9 MiB / 52.9 MiB (100 %) 4.2 MiB/s in 11s ETA: 0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
17.3 MiB / 17.3 MiB (100 %) 1.9 MiB/s in 7s ETA: 0s
info: installing component 'rust-std'
23.5 MiB / 23.5 MiB (100 %) 7.0 MiB/s in 3s ETA: 0s
info: installing component 'rustc'
52.9 MiB / 52.9 MiB (100 %) 3.9 MiB/s in 14s ETA: 0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
stable-x86_64-unknown-linux-gnu installed - rustc 1.56.1 (59eed8a2a 2021-11-01)
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
vscode 插件
rust-analyzer:它会实时编译和分析你的 Rust 代码,提示代码中的错误,并对类型进行标注。你也可以使用官方的 rust 插件取代。
rust syntax:为代码提供语法高亮。
crates:帮助你分析当前项目的依赖是否是最新的版本。
better toml:Rust 使用 toml 做项目的配置管理。better toml 可以帮你语法高亮,并展示 toml 文件中的错误。
rust test lens:可以帮你快速运行某个 Rust 测试。
Tabnine:基于 AI 的自动补全,可以帮助你更快地撰写代码。
安装 rust-src
[rusting@dev workspace]$ rustup component add rust-src
阅读离线样例代码
[rusting@dev workspace]$ git clone https://agit.ai/sol.ibm/rust-by-example-cn
Cloning into 'rust-by-example-cn'...
remote: Enumerating objects: 12794, done.
remote: Counting objects: 100% (12794/12794), done.
remote: Compressing objects: 100% (5791/5791), done.
remote: Total 12794 (delta 6825), reused 12782 (delta 6816), pack-reused 0
Receiving objects: 100% (12794/12794), 4.80 MiB | 201.00 KiB/s, done.
Resolving deltas: 100% (6825/6825), done.
Checking connectivity... done.
Checking out files: 100% (399/399), done.
编译
[rusting@dev workspace]$ cd rust-by-example-cn/
[rusting@dev rust-by-example-cn]$ cargo install mdbook
Updating crates.io index
作者介绍

Rust
V1
Code world !