Skip to content

Instantly share code, notes, and snippets.

@Dr-Emann
Forked from m10e/gist:15e93b31c6c47a5624d9
Last active August 29, 2015 14:01
Show Gist options
  • Save Dr-Emann/1d683f2ce03a053d9b06 to your computer and use it in GitHub Desktop.
Save Dr-Emann/1d683f2ce03a053d9b06 to your computer and use it in GitHub Desktop.
/*
Everything is in a single crate. The directory structure is as follows:
.
├── b
│   └── mod.rs
├── c
│   └── mod.rs
├── d
│   └── mod.rs
└── main.rs
*/
// -------------------- main.rs
mod b;
mod c;
// mod d goes here
mod d;
fn main() {
println!("{}", b::foo());
println!("{}", c::bar());
}
// -------------------- b/mod.rs
use d;
pub fn foo() -> int {
1 + d::baz()
}
// -------------------- c/mod.rs
// use `use` here, not mod.
use d;
pub fn bar() -> int {
2 + d::baz()
}
// -------------------- d/mod.rs
pub fn baz() -> int {
10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment