Skip to content

Instantly share code, notes, and snippets.

@daboross
Created December 4, 2014 08:21
Show Gist options
  • Save daboross/9a7abcbb5c3c931293c8 to your computer and use it in GitHub Desktop.
Save daboross/9a7abcbb5c3c931293c8 to your computer and use it in GitHub Desktop.
fn main() {
f1(Some(("value 1".to_string(), "value 2".to_string())))
}
fn f1(original: Option<(String, String)>) {
let shared = original.as_ref().map(|&(ref a, ref b)| (a.as_slice(), b.as_slice()));
f2(shared);
}
fn f2(shared: Option<(&str, &str)>) {
match shared {
Some((v1, v2)) => println!("Example: `{}` and `{}`", v1, v2),
None => println!("Nothing here!")
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment