Skip to content

Commit

Permalink
Note that try_validation_pat can take a format str directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
jumbatm committed May 1, 2020
1 parent 8304739 commit bd18ad4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/librustc_mir/interpret/validity.rs
Expand Up @@ -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 ),+ } )? $( , )?}) => {{
Expand Down

0 comments on commit bd18ad4

Please sign in to comment.