Rust 环境配置

Rust 的环境配置

Rust 安装

依旧一行命令

1
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

跟随指引傻瓜式安装即可

Cargo 配置

Cargo 的配置文件是 ~/.cargo/config.toml,可以在里面配置一些全局的 Cargo 选项,比如 registry、build、target 等等,这里我用的是 rsproxy 的源

config.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[source.crates-io]
replace-with = 'rsproxy-sparse'

[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"

[registries.rsproxy-sparse]
index = "sparse+https://rsproxy.cn/index/"

[net]
git-fetch-with-cli = true

[registry]
default = "rsproxy-sparse"

不过这个配置完好像不能直接 cargo search,以后研究一下