So I have three files- main.rs, vectors.rs, colors.rs
In vectors.rs I define a Vector struct and a Color alias for it.
In colors.rs I have a function that takes a Color as argument and prints something out.
Now the import in the colors.rs just doesn't work.
At the top of the colors.rs file I have this:
mod vectors;
use vectors::Color;
and at the top of main.rs (that doesn't give an error though):
mod vectors;
mod colors;
use vectors::Color;
use colors::*;
the compiler tells me to do this: https://dpaste.org/K8V7
but that's not how i want my folders to look like.
According to how you've written it, you actually have four modules:
A main module in main.rs
A vectors module, declared in main.rs and with its contents in vectors.rs
A colors module, declared in main.rd and with its contents in colors.rs
A colors::vectors module, declared in colors.rs and would have its contents in colors/vectors.rs (although that file presumably doesn't exist)
I think the use statement in colors.rs is interpreted relative to the current module, so it refers to colors::vectors::Color, which doesn't exist. You probably don't want the colors:: vectors module, so you can remove the mod statement in colors.rs, which declares it. You should also disambiguate the use in colors.rs to be relative to the crate root to ensure you are referencing the right thing: