Perfect, thanks Steven.
On Sun, Jun 1, 2014 at 8:27 PM, Steven Fackler wrote:
> Yep!
>
> main.rs:
>
> mod foo;
> mod bar;
>
> fn main() {
> foo::foo();
> }
>
> foo.rs:
>
> use bar; // this use lets you refer to the bar fn as bar::bar() instead of
> ::bar::bar()
>
> pub fn foo() {
> bar::b
Yep!
main.rs:
mod foo;
mod bar;
fn main() {
foo::foo();
}
foo.rs:
use bar; // this use lets you refer to the bar fn as bar::bar() instead of
::bar::bar()
pub fn foo() {
bar::bar();
}
bar.rs:
pub fn bar() {}
Steven Fackler
On Sun, Jun 1, 2014 at 5:25 PM, Nicholas Bishop
wrote:
>
My intent wasn't to make bar a submodule of foo, but rather that foo &
bar would be sibling modules (and foo just happens to use bar). Is
there a way to do that?
On Sun, Jun 1, 2014 at 6:56 PM, Steven Fackler wrote:
> The directory layout of the project should match the module hierarchy. bar
> is
The directory layout of the project should match the module hierarchy. bar
is a submodule of foo so it shouldn't live next to foo in the filesystem.
There are a couple of filesystem setups that will work:
src/
main.rs
foo/
mod.rs
bar.rs
src/
main.rs
foo/
Here's example code:
/src/main.rs:
mod foo;
fn main() {
foo::foo();
}
/src/bar.rs:
pub fn bar() {
}
/src/foo.rs:
mod bar;
pub fn foo() {
bar::bar();
}
This fails:
$ rust-nightly-x86_64-unknown-linux-gnu/bin/rustc -v
rustc 0.11.0-pre-nightly (064dbb9 2014-06-01 00:56:42 -0700)
host: x86_