-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Description
We can refer to modules in the same crate in different ways. For example, given a crate like this:
src/
lib.rs
a.rs
b.rs
a can import trait B in b as crate::b::B or super::b::B. And if B is pub use in lib.rs, a can also refer B as crate::B. All these work, but it is troublesome to think about which way to go every time. So I think it will be better if we have a guideline about this.
My opinion is that we should prefer referring things relatively using super::b::B because:
- It doesn't assume if
Bis public or not - When refactoring file structure, for example, if we want to move
a.rsandb.rsto a sub-directory, the code still works
Originally posted by @huachaohuang in rust-lang/api-guidelines#255
Metadata
Metadata
Assignees
Labels
No labels