Skip to content

Instantly share code, notes, and snippets.

@Kimundi
Last active December 10, 2015 18:48
Show Gist options
  • Save Kimundi/4476783 to your computer and use it in GitHub Desktop.
Save Kimundi/4476783 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";
)
...
}
With hypothetical field macros:
fn foo(a: Option<int>, b: Option<int>, c: Option<int>) {
arg_fail!( in "foo"
if a.matches!(None) : "a missing";
if b.matches!(Some(_)) : "Don't need b";
if b.matches!(None) && c.matches!(None) : "Need neither b nor c";
)
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment