我有一个锈蚀项目,带有以下cargo.toml:
[package]
name = "beefucurry-image"
version = "0.1.0"
authors = ["beefucurry <...>"]
edition = "2018"
[lib]
name = "beefucurry_image"
path = "src/lib.rs"
[[bin]]
name = "beefucurry_image_test"
path = "examples/basic.rs"
[bin.dependencies]
walkdir = "2"
并且当我使用“ cargo build”或“ cargo build --bin Beefucurry_image_test”进行编译时,出现以下错误:
warning: file found to be present in multiple build targets: C:\programs\VSCodeWorkspaces\RustProjects\beefucurry-image\examples\basic.rs
warning: unused manifest key: bin.0.dependencies
Compiling beefucurry-image v0.1.0 (C:\programs\VSCodeWorkspaces\RustProjects\beefucurry-image)
error[E0463]: can't find crate for `walkdir`
--> examples/basic.rs:3:1
|
3 | extern crate walkdir;
| ^^^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to previous error
我无法对cargo.toml使用“ examples”关键字/例外,因为这会中断调试,我必须使用显式的lib和bin。我如何说服铁锈导入walkdir?那警告是关于什么的?
我知道摆脱错误的一种方法是将[bin.dependencies]更改为[dependencies],但我希望这也会将依赖项也放到lib中。