I’m trying to create a project that builds both a lib and a bin, but I’m having problems getting the compiler to recognize a module when building.
Here’s my project tree:
Here’s the error I get when I have the module in the src dir:
error[E0583]: file not found for module `hasher` --> src\lib.rs:1:9 | 1 | pub mod hasher; | ^^^^^^ | = help: name the file either lib\hasher.rs or lib\hasher\mod.rs inside the directory "src"
So I’ve done what the compiler suggests and move the file to lib\hasher like so:
Now I get the following error:
error[E0583]: file not found for module `hasher` --> src/lib.rs:1:9 | 1 | pub mod hasher; | ^^^^^^ | = help: name the file either hasher.rs or hasher\mod.rs inside the directory "src"
I have no idea how to get this to compile. Any advice?
Here’s the contents of my Cargo.toml if that matters:
[package] name = "tool" version = "0.1.0" authors = ["Jeramy<email@example.com>"] edition = "2018" [dependencies] crypto-hash = "0.3.3" filebuffer = "0.4.0" [lib] name = "hasher" path = "src/lib.rs" [[bin]] name = "tool" path = "src/main.rs"