diff options
Diffstat (limited to 'rfc2822/src/macros.rs')
-rw-r--r-- | rfc2822/src/macros.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/rfc2822/src/macros.rs b/rfc2822/src/macros.rs new file mode 100644 index 00000000..9418f2e2 --- /dev/null +++ b/rfc2822/src/macros.rs @@ -0,0 +1,19 @@ +// Turns an `if let` into an expression so that it is possible to do +// things like: +// +// ```rust,nocompile +// if destructures_to(Foo::Bar(_) = value) +// || destructures_to(Foo::Bam(_) = value) { ... } +// ``` +macro_rules! destructures_to { + ( $error: pat = $expr:expr ) => { + { + let x = $expr; + if let $error = x { + true + } else { + false + } + } + }; +} |