Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

Commit

Permalink
matches: Remove _matches_tt_as_expr_hack, it is redundant in Rust 1.12+
Browse files Browse the repository at this point in the history
  • Loading branch information
bluss committed Apr 4, 2017
1 parent 6f1c257 commit b696bae
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions matches/lib.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
#[macro_export]
macro_rules! matches {
($expression:expr, $($pattern:tt)+) => {
_matches_tt_as_expr_hack! {
match $expression {
$($pattern)+ => true,
_ => false
}
match $expression {
$($pattern)+ => true,
_ => false
}
}
}

/// Work around "error: unexpected token: `an interpolated tt`", whatever that means.
#[macro_export]
macro_rules! _matches_tt_as_expr_hack {
($value:expr) => ($value)
}

#[macro_export]
macro_rules! assert_matches {
($expression:expr, $($pattern:tt)+) => {
_matches_tt_as_expr_hack! {
match $expression {
$($pattern)+ => (),
ref e => panic!("assertion failed: `{:?}` does not match `{}`", e, stringify!($($pattern)+)),
}
match $expression {
$($pattern)+ => (),
ref e => panic!("assertion failed: `{:?}` does not match `{}`", e, stringify!($($pattern)+)),
}
}
}
Expand Down

0 comments on commit b696bae

Please sign in to comment.