Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
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