Created
May 29, 2014 15:34
-
-
Save Dr-Emann/77f6beb2e86687a4f325 to your computer and use it in GitHub Desktop.
Demonstration of rust modules in files
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
//--------------- main.rs --------------------- | |
use a::b; | |
mod a; | |
mod c; | |
fn main() { | |
println!("{}", a::foo); | |
c::foobar(); | |
println!("{}", b::bar); | |
} | |
//-------------- a/mod.rs --------------------- | |
pub mod b; | |
pub static foo: int = 40; | |
//-------- a/b.rs (or a/b/mod.rs) ------------- | |
pub static bar: f64 = 1.1; | |
//----------------- c.rs ---------------------- | |
// no need to use mod | |
use a::b; | |
pub fn foobar() { | |
println!("{}", b::bar); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment