1. Rustup镜像

export RUSTUP_DIST_SERVER="https://mirrors.ustc.edu.cn/rust-static"
export RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup"

RUSTUP_DIST_SERVER=https://static.rust-lang.org
RUSTUP_UPDATE_ROOT=https://static.rust-lang.org/rustup

# 清华大学
RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup

# 中国科学技术大学
RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup

# 上海交通大学
RUSTUP_DIST_SERVER=https://mirrors.sjtug.sjtu.edu.cn/rust-static/

2. Rustup

Command Description

rsutup show

列出现在使用的和已安装的rust版本

rustup update

更新所有已安装版本,nightly会日更新,故谨慎更新

rustup default

设置将要使用的版本

rustup self uninstall

卸载Rust

rustup component <sub>

列出(list),安装(add),移除(remove)组建

rustup update

rustup component add rls rust-analysis rust-src

# 安装代码格式化工具Rustfmt
rustup component add rustfmt

# 安装代码校验工具Clippy
rustup component add clippy

3. Cargo镜像

  • $HOME/.cargo/config:C:/Users/userName/.cargo/config

[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"

# 指定镜像,如:tuna、sjtu、ustc,或rustcc
replace-with = 'sjtu'

# 注:配置源,配一个即可

# 中国科学技术大学
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"

# 上海交通大学
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index/"

# 清华大学
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

# rustcc社区
[source.rustcc]
registry = "https://code.aliyun.com/rustcc/crates.io-index.git"

4. Cargo

Command Description

cargo build

编译当前包,构建项目

cargo check

检查当前包并寻出错误,但不进行编译

cargo clean

删除编译结果(即target文件夹)

cargo doc

为项目构建文档,构建当前包以及依赖项得文档,https://docs.rs

cargo new

新建一个crate

cargo init

以当前文件夹初始化一个crate

cargo run

编译并执行src/main.rs

cargo test

执行测试项

cargo bench

执行基准测试项

cargo update

更新所需的依赖项并预编译

cargo search

搜索crates

cargo publish

打包发布,将库发布到crates.io

cargo install

安装cargo相关可执行文件,默认路径为$HOME/.cargo/bin

cargo uninstall

卸载相关可执行文件

cargo install racer

cargo install rustsym

cargo install rustfmt

cargo install ripgrep

cargo build

cargo run

5. Trackback

Url Memo

Common

https://www.rust-lang.org

Rust官网

https://docs.rs

Doc Rust

https://rocket.rs

Rocket Rust

https://cheats.rs

Rust Cheat Sheet

https://play.rust-lang.org

Rust Playground

https://rustcc.cn

Rust语言中文社区

Rust Doc

https://doc.rust-lang.org/std/index.html

Rust标准库

https://doc.rust-lang.org/edition-guide/index.html

Rust版本指南

https://doc.rust-lang.org/cargo/index.html

Rust包管理器和构建系统

https://doc.rust-lang.org/rustdoc/index.html

为crate编写文档

https://doc.rust-lang.org/rustc/index.html

Rust编译器可用选项

https://doc.rust-lang.org/error_codes/error-index.html

编译错误索引表

https://doc.rust-lang.org/stable/rust-by-example/

Rust Example

https://doc.rust-lang.org/clippy/

Clippy

https://doc.rust-lang.org/book/

Book

https://doc.rust-lang.org/stable/embedded-book/

Embedding Book

Rare

https://rust.e.lntu.edu.cn/

Rust相关中文文档

https://space.bilibili.com/25566598

Rust语言中文社区

https://blog.csdn.net/u012067469?type=blog

Rust语言中文社区

https://rust-cli.github.io/book/index.html

命令行

https://rustwasm.github.io/docs/book/

WebAssembly构建浏览器原生的库

https://docs.rust-embedded.org/book/index.html

微控制器和嵌入式系统程序

https://forge.rust-lang.org/

贡献者文档

https://www.rust-lang.org/policies/code-of-conduct

代码规范

https://jmeubank.github.io/tdm-gcc/

Win环境gcc编译器

https://kaisery.github.io/trpl-zh-cn/

https://foundation.rust-lang.org/policies/privacy-policy/

https://www.rust-lang.org/policies/security

https://rustc-dev-guide.rust-lang.org/

https://www.youtube.com/@RustVideos/videos

https://webassembly.org/

https://developer.mozilla.org/en-US/docs/WebAssembly

https://docs.rust-embedded.org/discovery/index.html

https://github.com/rust-lang/rfcs

https://www.rust-lang.org/learn/get-started

https://github.com/rust-lang/rust-analyzer/releases

https://github.com/rust-lang/rustfmt

https://download.eclipse.org/corrosion/

https://archive.eclipse.org/

https://rust-lang.github.io/rustup/

https://rustlings.cool/

https://blog.rust-lang.org

Blog