Welcome, this question is for sure repeated, but for past 2 hours my mod
didn't work and im sure I've done everything correctly.
Here is my tree:
project \
|- target...
|
|- rust_stuff...
|
\- src
|- main.rs
|
|- first_file.rs
|
\- second_file.rs
And here is second one, for reference when i will list what i tried:
project \
|- target...
|
|- rust_stuff...
|
\- src
|- main.rs
|
|- first_file.rs
|
\- cool_folder
|
\second_file.rs
Ok, so we have:
// -- MAIN --
mod first_file;
pub use first_file::*;
fn main() {
call_first();
}
Now, first_file.rs contains
// -- FIRST_FILE --
mod second_file; //E: Not found
pub use second_file; //E: Not used
pub fn call_first(){
call_second(); //E: Out of scope
}
I will stop here, second_file
exists, and cannot be accesed by first_file
but can be accessed by main
just like this:
// -- MAIN --
mod first_file;
pub use first_file::*;
mod second_file;
pub use second_file::*;
fn main() {
call_first(); //Would call 'call_second' but as i presented it can't
call_second(); //Returns "Hello world" in terminal
}
(Thats assuming second_file is same as first_file with just different function naming)
Now, reffering to second tree i showed, i tried putting those files in cool_file
, but it worked out the same except i used:
mod cool_file; //Err
pub use cool_file::*;
// this does not work
pub use second_file::*;
// neither does this
In documentation from what i understand, i wrote it the right way, in regards to first example, i have no idea what to do. Please help.