Let's assume we have the following file tree:
src
|--bin
| |--hw.rs
|--libs
| |--streams.rs
| |--structs.rs
|--main.rs
I want to access some structs from the structs module inside the hw file, however it doesn't compile, as it can't find lib::structs whatever I do.
The main.rs file contains the following:
mod streams;
mod structs;
use streams::{X, Y, Z};
use structs::{A, B, C, D, E};
(some more code)
The streams.rs file contains the following:
use crate::structs::{A, B, C, D, E};
(some more code)
The structs.rs file contains the following:
use crate::structs::{A, B, C, D, E};
(some more code)
The hw.rs file contains the following:
use crate::libs::structs::{A, B};
use polars::prelude::*;
(some more code)
This throws the following Error:
error[E0433]: failed to resolve: could not find `libs` in the crate root
--> src/bin/hw.rs:7:12
|
7 | use crate::libs::structs::{A, B};
| ^^^^ could not find `libs` in the crate root
I have tried to add the following at the top of hw.rs
// #[path = "../libs"]
// mod streams;
// mod structs;
It didn't work, I tried using the super keyword, it didn't work. Generally, every solution I've tried the past 2 days (removing crate from the import line, trying to access structs directly etc.) that worked for others didn't work for me. I also tried to create a workspace in case I could work around this issue but still had the same problem.
So? What am I doing wrong, and thus, what have I not understood correctly?