rust下载及rustup,cargo的使用
在 Linux 或 macOS 上安装 rustup
打开终端并输入下面命令:
$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
在 Windows 上安装 rustup
1. 先安装C++环境
2.安装rust
查看rust是否安装成功
C:\Users\Edgar>rustc -V
rustc 1.76.0 (07dca489a 2024-02-04)
C:\Users\Edgar>cargo -V
cargo 1.76.0 (c84b36747 2024-01-1
这样就安装好了
创建项目
cargo new hello_world
cd hello_world
cargo new 命令用来创建项目
运行项目
cargo run
在终端可以输出“Hello, world”。
cargo的使用
-
cargo run //编译并运行
- cargo run --release //编译慢,优化运行速度
-
cargo build //构建项目
- cargo build --release //优化运行速度
-
cargo check //快速检查错误