From bd18ad4fef9ca3d618521b8268183497b6104ff9 Mon Sep 17 00:00:00 2001 From: jumbatm Date: Fri, 1 May 2020 21:49:42 +1000 Subject: [PATCH] Note that try_validation_pat can take a format str directly. --- src/librustc_mir/interpret/validity.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 54da0ba9eed..fe584596f01 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -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 { ($e:expr, $where:expr, { $( $p:pat )|+ => { $( $what_fmt:expr ),+ } $( expected { $( $expected_fmt:expr ),+ } )? $( , )?}) => {{