在cargo.toml中添加
[[bin]]name = "test"path = "src/main_test.rs"// 如果是lib[lib]name = "test"path = "src/main_lib.rs"
运行
cargo run --bin test
设置默认运行test,在cargo.toml中添加default-run = "test"
[package]name = "xmbcli"version = "0.1.0"authors = ["root"]edition = "2018"default-run = "test"
**
另一种方式,可以把rs文件放在src/bin目录下,运行时会自动识别,不需要再改cargo.toml
cargo run --bin main_test
