Skip to content

Rust工程构建

第一步:

shell
cargo new world_hello
cd world_hello

然后用 vscode 打开 world_hello 文件夹

构建:(默认为 debug)

shell
cargo build
cargo build --release

运行:

shell
cargo run
cargo run --release

(不需要手动运行,在 mian.rs 里,会自动有 run 和 debug 按钮)

检查是否过编译:

shell
cargo check

(不需要手动运行,因为 vsc 代码服务器会自动运行并标红)

调试: 在 vscode 里点 debug 按钮,添加断点就能自动停下,看变量、堆栈

格式化:

shell
cargo fmt