1.mac 要下载 Rustup 并安装 Rust,请在终端中运行以下命令,然后遵循屏幕上的指示。
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
2.检查是否安装成功
rustc -V
cargo -V
3.编译器 rustc 和包管理器 cargo升级命令
rustup update
rustup update 命令会执行以下操作:
- 更新 rustup 本身: 检查并更新 rustup 工具到最新版本(如果需要)。
- 更新工具链: 检查并下载您当前使用的默认工具链(Toolchain)的最新稳定版本。工具链通常包括:
- rustc (Rust 编译器)
- cargo (包管理器和构建工具)
- rust-std (标准库)
- rust-docs (标准库文档)
安装新的组件: 如果有新组件被添加到默认工具链中,它也会自动安装。
4.卸载命令
rustup self uninstall
5.cargo是Rust 构建工具和包管理器,常用命令
- cargo build 可以构建项目
- cargo run 可以运行项目
- cargo test 可以测试项目
- cargo doc 可以为项目构建文档
- cargo publish 可以将库发布到 crates.io。