Skip to content

Instantly share code, notes, and snippets.

@bstrie
Created November 16, 2012 03:31
Show Gist options
  • Select an option

  • Save bstrie/4083782 to your computer and use it in GitHub Desktop.

Select an option

Save bstrie/4083782 to your computer and use it in GitHub Desktop.
pub pure fn get_default_with<T>(def: T, f: fn() -> Option<T>) -> T {
match f() { Some(x) => move x, None => move def }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment