macro_rules! match_ok { ($in:expr, $(|)? $($p:pat)|+ $(if $guard:expr)? => $out:expr $(,)?) => { ... }; ($in:expr, $(|)? $($p:pat)|+ $(if $guard:expr)? $(,)?) => { ... }; (, $($pattern_and_rest:tt)*) => { ... }; }
Expand description
Try to match $in
against a given pattern $p
. Produces Some($out)
if
successful; None
otherwise.
ⓘ
match_ok!($( $in:expr )?, $p:pat_multi $( if $guard:expr )? $( => $out:expr )? $( , )?)
=> $out
can be left out, in which case it’s implied in the same way as
try_match!
.
$in
can be left out to produce a closure (partial
application).
See the crate-level documentation for examples.