Skip to content

Instantly share code, notes, and snippets.

@brson
Created November 4, 2012 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brson/4013692 to your computer and use it in GitHub Desktop.
Save brson/4013692 to your computer and use it in GitHub Desktop.
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