I have included a library as a submodule in my program. The structure looks like this:
.
├── my_lib/
│ ├── Cargo.toml
│ └── src/
│ ├── lib/
│ │ ├── mod.rs
│ │ └── foo.rs
│ └── main.rs
├── src/
│ └── main.rs
└── Cargo.toml
In my program's Cargo.toml
file I have added the dependency following this answer:
[dependencies]
my_lib = { path = "./my_lib" }
However I'm not able to use this library inside my program, I'm a bit new to Rust and this import system is very confusing to me. I've tried this in main.rs
:
use my_lib::foo;
But I get an unresolved import 'my_lib'
error.
my_lib/src
? I would expectmy_lib/src/lib.rs
. What's thatlib/
directory ? – PilferCargo.toml
files are. You also don't show any Rust files (and their contents) inside ofmy_lib
. It would make it easier for us to help you if you try to reproduce your error in a brand new Cargo project, then edit your question to include the additional info. There are Rust-specific MRE tips you can use to reduce your original code for posting here. Thanks! – Skawlib.rs
file, not amain.rs
one. That's probably your first problem. – Pilfer