Macro try_match::try_match[][src]

macro_rules! try_match {
    ($in : expr, $(|) ? $($p : pat) | + $(if $guard : expr) ? => $out : expr) => { ... };
    ($in : expr, $(|) ? $($p : pat) | + $(if $guard : expr) ?) => { ... };
}
Expand description

Try to match $in against a given pattern $p. Produces Ok($out) if successful; Err($in) otherwise.

=> $out can be left out, in which case it’s implied based on the number of bound variables in $p:

  • If there are no bound variables, it is implied to be ().
  • If there is exactly one bound variable var, it is implied to be var.
  • If there are multiple bound variables var1, var2, ..., it is implied to be AnonymousType { var1, var2 }.

AnonymousType implements Clone, Copy, and Debug.

See the crate-level documentation for examples.