这是我的目录结构:
lowks@lowkster ~/src/rustlang/gettingrusty $ tree .
.
├── Cargo.lock
├── Cargo.toml
├── foo.txt
├── src
│ ├── boolean_example.rs
│ ├── function_goodbye_world.rs
│ ├── listdir.rs
│ ├── looping.rs
│ ├── main.rs
│ ├── pattern_match.rs
│ └── write_to_file.rs
└── target
├── build
├── deps
├── examples
├── gettingrusty
└── native
6 directories, 11 files
当我运行“cargo build”时,它似乎只构建了 main.rs
。我应该如何更改 Cargo.toml 以构建其余文件?
最佳答案
将other.rs
文件放入src
文件夹的bin
子文件夹中(./src/bin/other.rs
)。并运行 cargo build --bin other
或 cargo run --bin other
关于rust - 我如何告诉 Cargo 构建 main.rs 以外的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27613874/