My project structure looks like this:
.
├── Cargo.lock
├── Cargo.toml
└── src
├── bin
│ └── other.rs
├── main.rs
└── util.rs
(code: https://gitlab.com/msrd0/cargo-bin-import)
In my other.rs
, I'm trying to reuse code from the util
mod, which is declared as a public mod in my main.rs
file. I tried the following:
use util::do_sth
use crate::util::do_sth
use cargo_bin_import::util::do_sth
(with and without extern crate)mod util; use util::do_sth
extern crate util; use util::do_sth
(suggested by rustc)
None of the above worked and gave me error messages similar to this one:
error[E0432]: unresolved import `crate::util`
--> src/bin/other.rs:1:12
|
1 | use crate::util::do_sth;
| ^^^^ maybe a missing `extern crate util;`?
error: aborting due to previous error