Hello everyone!
I'm dealing with module hierarchy. I have:
src/
ecs/
foo.rs
bar.rs
ecs.rs
main.rs
With ecs.rs
exposing module content:
// ecs.rs
mod foo;
pub use foo::do_something;
So I use ecs
content in main.rs
with:
// main.rs
mod ecs;
use crate::ecs;
ecs::do_something()
OK.
Now I want to use bar.rs
content in foo.rs
.
My only working solution is to add bar
as mod
:
// ecs.rs
mod foo;
mod bar; // declared here
pub use foo::do_something;
And use it in foo.rs
like this:
// foo.rs
use crate::ecs::bar;
pub fn do_something() {
bar::hello();
}
My problem is about giving the whole path:
use crate::ecs::bar;
I would like something that doesn't depends on full ecs
path. A python-ish way would be:
// foo.rs
use .bar;
use crate::.::bar;
ecs
module is a black box, internals shouldn't even known its name.
So, how foo.rs
or bar.rs
could use
each other without having to specify the parent module name? What am I missing?
Thanks in advance!