UPDATE:
The problem is solved by moving extern crate my_library; into my_project/src/lib.rs.
===================================================================================
I have two projects with the following structures:
. my_library
├── Cargo.toml
└── src
└── lib.rs
└── client.rs
└── server.rs
. my_project
├── Cargo.toml
└── src
└── client
└── mod.rs
└── db
└── mod.rs
I want to include structs/functions from my_library in my_project/src/client/mod.rs and my_project/src/db/mod.rs.
- lib.rs defines
struct MyQueryandstruct MyReply. - client.rs defines
struct MyClient. - server.rs defines
struct MyServer. - Within
lib.rsit haspub mod client;pub mod server;
Following the answer here https://stackoverflow.com/questions/45519176/how-do-i-use-or-import-a-local-rust-file, I added the path of my_library into my_project/Cargo.toml and tried the following:
extern crate my_library;
use my_library::client::MyClient;
use my_library::server::MyServer;
use my_library::MyQuery;
use my_library::MyReply;
Then the compiler throws out error:
error[E0433]: failed to resolve: unresolved import
help: a similar path exists: client::my_library
What would be the correct way to import?