[rust-dev] Modules and visibility

Patrick Walton pcwalton at mozilla.com
Thu Jan 23 10:59:10 PST 2014

On 1/22/14 12:37 PM, Matthias Einwag wrote:
> 1. A real splitting between source files and modules
>     One solution is an alternative include to mod Otherfile; That would
> not automatically create a new module and put the content of the file in it.
>     So basically the same as C++ include. I know there's include!, but
> is discouraged and from my tests also did not work for including types.
>     The other option is to have something like Dart. There you have a
> top level file for you module/library, where you specify which other
> files are part of the module.
>     Like `part "otherfile.rs <http://otherfile.rs>";` In the other files
> you specify `part of myModule;` to make clear that they belong to each
> other.

For engineering reasons I really like the fact that you can always find 
the definition of any name by simply looking in the same file. Any name 
"foo" is always:

1. Defined in the same file.

2. Imported at the top of the file.

3. Defined in the prelude.

For large projects, this eliminates a lot of grepping through the codebase.


More information about the Rust-dev mailing list