Skip to content

Instantly share code, notes, and snippets.

@bstrie
Forked from Kimundi/gist:4476783
Last active December 10, 2015 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bstrie/4476802 to your computer and use it in GitHub Desktop.
Save bstrie/4476802 to your computer and use it in GitHub Desktop.
fn foo(a: Option<int>, b: Option<int>, c: Option<int>) {
arg_fail!( in "foo"
if matches!(a: None) : "a missing";
if matches!(b: Some(_)) : "Don't need b";
if matches!(b: None) && matches!(c: None) : "Need neither b nor c";
)
...
}
// multimatch pattern
fn foo(a: Option<int>, b: Option<int>, c: Option<int>) {
match (a, b, c) {
(None, _, _) => "a missing",
(_, Some(_), _) => "Don't need b";
(_, None, None) => "Need neither b nor c";
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment