-
-
Save Dr-Emann/1d683f2ce03a053d9b06 to your computer and use it in GitHub Desktop.
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