Forked from m10e/gist:15e93b31c6c47a5624d9
Last active
August 29, 2015 14:01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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