Created
November 4, 2012 20:44
-
-
Save brson/4013692 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
pub pure fn get_default_ref<T>(opt: &r/Option<T>, def: &r/T) -> &r/T { | |
match *opt { | |
Some(ref x) => x, | |
None => def | |
} | |
} | |
fn main() { | |
match os::homedir() { | |
None => { | |
io::println("You have no home folder :-("); | |
} | |
Some(ref homedir) => { | |
io::println("Files in your home folder:"); | |
for os::list_dir_path(homedir).each |path| { | |
let name = &path.filename(); | |
let default = &~"?"; | |
io::println(*get_default_ref(name, default)); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment