在安装rust的时候和更新rust依赖的时候在国内我们可能会遇到下载奇慢的问题.
这个时候可以通过配置镜像站点,加速加载.
rustup(rust-init) 加速
Windows 下 如果发现rust-init.exe 不能成功下载工具链,一直卡在下载上.
此时可以打开CMD
set RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
set RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
C:甥敳獲aron900Downloads>set RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-staticC:甥敳獲aron900Downloads>set RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustupC:甥敳獲aron900Downloads>"rustup-init (1).exe"Welcome to Rust!This will download and install the official compiler for the Rustprogramming language, and its package manager, Cargo.It will add the cargo, rustc, rustup and other commands toCargo's bin directory, located at: C:甥敳獲aron900.cargobinThis can be modified with the CARGO_HOME environment variable.Rustup metadata and toolchains will be installed into the Rustuphome directory, located at: C:甥敳獲aron900.rustupThis can be modified with the RUSTUP_HOME environment variable.This path will then be added to your PATH environment variable bymodifying the HKEY_CURRENT_USER/Environment/PATH registry key.You can uninstall at any time with rustup self uninstall andthese changes will be reverted.Current installation options: default host triple: x86_64-pc-windows-msvc default toolchain: stable profile: default modify PATH variable: yes1) Proceed with installation (default)2) Customize installation3) Cancel installation>1info: profile set to 'default'info: default host triple is x86_64-pc-windows-msvcinfo: syncing channel updates for 'stable-x86_64-pc-windows-msvc'467.6 KiB / 467.6 KiB (100 %) 340.0 KiB/s in 2s ETA: 0sinfo: latest update on 2020-08-27, rust version 1.46.0 (04488afe3 2020-08-24)info: downloading component 'cargo'info: downloading component 'clippy'info: downloading component 'rust-docs'info: downloading component 'rust-std'info: downloading component 'rustc'info: downloading component 'rustfmt'info: installing component 'cargo'info: installing component 'clippy'info: installing component 'rust-docs' 12.6 MiB / 12.6 MiB (100 %) 5.3 MiB/s in 2s ETA: 0sinfo: installing component 'rust-std'info: installing component 'rustc' 39.5 MiB / 39.5 MiB (100 %) 14.3 MiB/s in 2s ETA: 0sinfo: installing component 'rustfmt'info: default toolchain set to 'stable' stable installed - rustc 1.46.0 (04488afe3 2020-08-24)Rust is installed now. Great!To get started you need Cargo's bin directory (%USERPROFILE%.cargobin) in yourPATHenvironment variable. Future applications will automatically have thecorrect environment, but you may need to restart your current shell.Press the Enter key to continue.
下载速度飞起!!
crate.io 镜像加速(Rust Crates 源加速)
在 $HOME/.cargo/config 中添加如下内容,如果不存在就新创建一个 config 文件.
[source.crates-io]replace-with = 'ustc'[source.ustc]registry = "git://mirrors.ustc.edu.cn/crates.io-index"
如果你的网络环境不支持git的话,可以把registry替换成:
registry = "https://mirrors.ustc.edu.cn/crates.io-index"