I’ve read the section in the Rust Book on importing crates but I am still missing something.
I have a project structure like:
hello_world
├── Cargo.lock
├── Cargo.toml
└── src
├── auth
│ └── mssql.rs
├── auth.rs
├── pipeline.rs
└── main.rs
my code looks like:
main.rs
pub mod pipeline;
use crate::pipeline::Pipeline;
fn main() {
let p = Pipeline {credentials: "my_user".to_string()};
}
pipeline.rs
use crate::auth::mssql; // error here
pub struct Pipeline {
pub credentials: String,
}
impl Pipeline {
pub fn get_auth() {
mssql::authenticate();
}
}
auth.rs
pub mod mssql;
mssql.rs
pub fn authenticate() {
println("authenticated");
}
I receive the following error:
use auth::mssql;
| ^^^^ use of undeclared crate or module `auth`
I’ve looked at many examples of similar issues online but cannot wrap my head around why I am getting this error.
If I understand correctly based on the book example here, this should work.
Isn’t use crate::auth::mssql
supposed to look in auth.rs
and find the included mssql.rs
via pub mod mssql
?
1