1
Fork 0

Note that try_validation_pat can take a format str directly.

This commit is contained in:
jumbatm 2020-05-01 21:49:42 +10:00
parent 830473959a
commit bd18ad4fef

View file

@ -66,6 +66,15 @@ macro_rules! try_validation {
/// }); /// });
/// ``` /// ```
/// ///
/// An additional nicety is that both parameters actually take format args, so you can just write
/// the format string in directly:
///
/// ```
/// let v = try_validation_pat!(some_fn(), some_path, {
/// Foo | Bar | Baz => { "{:?}", some_failure } expected { "{}", expected_value },
/// });
/// ```
///
macro_rules! try_validation_pat { macro_rules! try_validation_pat {
($e:expr, $where:expr, { $( $p:pat )|+ => ($e:expr, $where:expr, { $( $p:pat )|+ =>
{ $( $what_fmt:expr ),+ } $( expected { $( $expected_fmt:expr ),+ } )? $( , )?}) => {{ { $( $what_fmt:expr ),+ } $( expected { $( $expected_fmt:expr ),+ } )? $( , )?}) => {{