Skip to content

Rust

安装

MacOS

安装

bash
# Install Toolchain Manager
brew install rustup
# Install Rust Compiler
rustup-init
#
source ~/.zshrc
# Verify Your Installation
rustc --version

镜像

bash
touch ~/.cargo/config.toml
bash
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true

~/.zshrc or ~/.bashrc

bash
export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"

Windows

bash
setx RUSTUP_DIST_SERVER "https://rsproxy.cn"
setx RUSTUP_UPDATE_ROOT "https://rsproxy.cn/rustup"
setx CARGO_HOME "D:\Tools\Rust\cargo"
setx RUSTUP_HOME "D:\Tools\Rust\rustup"

新建配置文件

bash
D:\Tools\Rust\cargo\config.toml

配置如下

bash
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true