Create a library in same directory as a workspace member, instructed by https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html but when use in the main.rs, it told the above error. but the config I checked is correct. here is the screenshots. I search this error but didn't find any help.
#[Solved] unresolved import `lib` no external crate `lib` in the worksapce
5 messages · Page 1 of 1 (latest)
I don't think you can have the same Cargo.toml be both a cargo project and a cargo workspace.
I normally use this structure, try doing this
project/
Cargo.toml <-- workspace Cargo.toml
lib/
Cargo.toml
app/
Cargo.toml
Yes, you are right. I got the wrong folder level. The two cargo projects should under the root project. Thanks so much.
[Solved] unresolved import lib no external crate lib in the worksapce
it is in fact possible to have a package and a workspace with the same file https://doc.rust-lang.org/cargo/reference/workspaces.html#root-package
though this has the effect of cargo commands defaulting to acting on the root package instead of the entire workspace, so I don't recommend it