For what it's worth, this is how things used to work, but we changed it because it was annoying to have the "main code" for a module in a different directory from its submodules.

Joe Fredette wrote:
(believe I missed reply-to-all the first time I tried this, apologies for the double-email, Brian)

Speaking as a newb who struggled with how to do this not long ago. My expectation (which I knew was wholly unfounded) was that I could simply have `driver.rs <http://driver.rs/>` _and_ `driver/` for the various submodules of driver. In my case the goal was to distinguish different implementations of a common trait (namely, 'Command' which is a set of things which can be run). The intention was to have `command.rs <http://command.rs/>` contain the trait definition and factory function, and then have the directory contain the various implemnentations (builtin, invocation, pipeline, etc).

The eventual solution was somewhat confusing, and can be found (in a more abstract form) on my github at jfredett/rust_mod_test [1] on the 'fixed' branch. I won't go into what the solution was, my point was merely to offer that -- my assumption, at least, would be that there is simply a <module>.rs and if I want a directory with submodules, I make that. The assumption derives from the Ruby convention of having `foo.rb` require all the necessary functionality out of `foo/`, and usually it contains cross-submodule functionality as well.


[1] https://github.com/jfredett/rust_mod_test


On Feb 20, 2013, at 7:41 PM, Brian Anderson <[email protected] <mailto:[email protected]>> wrote:

On 02/20/2013 01:15 AM, Sanghyeon Seo wrote:
rustc.rc has:

#[path = "metadata/mod.rs"]
pub mod metadata;
#[path = "driver/mod.rs"]
pub mod driver;

I think this should be the default. "mod" is a keyword anyway.
What do you think?


Because sometimes `mod driver;` means look in the current directory, and sometimes it means look in a subdirectory, doing this would require that, when the parser sees `pub mod driver;`:

1) look in the current directory for `driver.rs`
2) if that fails, look in the `driver` directory for `mod.rs`

That's not necessarily bad, but it's a small bit of non-obvious behavior. I haven't been thrilled with the `mod.rs` convention (because my emacs buffers all have the same name) so I haven't been using it on new code, but I think if we go with the `lib.rs`/`bin.rs`/`pkg.rs` naming for crates in packages, then we should also settle on `mod.rs` for directory modules, in which case I think I'm fine with this change.
_______________________________________________
Rust-dev mailing list
[email protected] <mailto:[email protected]>
https://mail.mozilla.org/listinfo/rust-dev

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to