Skip to content

Instantly share code, notes, and snippets.

/*
Everything is in a single crate. The directory structure is as follows:
.
├── b
│   └── mod.rs
├── c
│   └── mod.rs
├── d
│   └── mod.rs
@Dr-Emann
Dr-Emann / gist:77f6beb2e86687a4f325
Created May 29, 2014 15:34
Demonstration of rust modules in files
//--------------- main.rs ---------------------
use a::b;
mod a;
mod c;
fn main() {
println!("{}", a::foo);
c::foobar();
@Dr-Emann
Dr-Emann / a.rs
Created May 29, 2014 15:27
Rust Module Demonstration
// 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;