Include structs from another project

The problem is solved by moving extern crate my_library; into my_project/src/

I have two projects with the following structures:

. my_library
  ├── Cargo.toml
  └── src
. my_project
├── Cargo.toml
└── src
    └── client
    └── db

I want to include structs/functions from my_library in my_project/src/client/ and my_project/src/db/

  • defines struct MyQuery and struct MyReply.
  • defines struct MyClient.
  • defines struct MyServer.
  • Within it has pub mod client; pub mod server;

Following the answer here, 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?

My understanding : as of Rust 2018 you don't need to use extern at all. I haven't ever used it. See

Thanks for the reply. I'm working on two old projects, so I use extern for consistency.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.