Skip to content

Quick referrence table

Rustup

sh
rustup self update # 更新 rustup
rustup update # 更新 toolchain

一个 toolchain 有几种 channel(e.g. nightly), 包含不同的 components(e.g. rustc, cargo..)。每个 channel 可以听过 profile(mininal/default/complete)选择不同数量的 components.

可以通过在项目目录下方式 rust-toolchain.toml 来强制指定当前项目所使用的 rust 版本以及上述 toolchain 信息。

Cargo

sh
cargo new project_name # 新建一个标准的 rust 项目
cargo update         # 更新项目的所有依赖
cargo update regex   # 更新依赖 regex
cargo add package_name # 新建一个 package
cargo build --features x # 编译包含 feature 的 target
cargo run --features x # 运行包含 feature 的 target, 如果 target 并没有 feature 则编译再运行