-
-
Save Dr-Emann/d2e7d16cf821509b9809 to your computer and use it in GitHub Desktop.
Rust Module Demonstration
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
// you can just use | |
// `pub mod b;` | |
// if this file is a/mod.rs and | |
// if you have a file named a/b.rs or a/b/mod.rs | |
// that contains the contents inside the curly brackets | |
pub mod b { | |
pub static bar: f64 = 1.1; | |
} | |
pub static foo: int = 40; |
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
use a::b; | |
pub fn foobar() { | |
println!("{}", b::bar); | |
} |
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
use a::b; | |
mod a; | |
mod c; | |
fn main() { | |
println!("{}", a::foo); | |
c::foobar(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment