Handling module/ + crate name conflict

Suppose we have

main.rs
foo.rs

and in main.rs, we have

extern crate foo; // some external crate

mod foo; // referring to the foo.rs

In this world, is it possible to specify which foo we are referring to?

You can't have two things in the same place with the same name. It's like having struct foo; enum foo;, but you can rename them:

extern crate foo as the_other_foo;

or

#[path="foo.rs"]
mod the_foo_mod;

and, if I recall correctly, in the next edition it will also be ::foo for the crate, and crate::foo for the module.

1 Like