From 8bb069ba1c7c5c14dc359258e557b648dbab92a6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 14 Mar 2021 19:31:50 +0000 Subject: [PATCH] utils: Improve matches_doesnot Signed-off-by: Ian Jackson --- src/utils.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index e2095f54..4a4a29b6 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -349,8 +349,8 @@ impl IteratorExt for T where #[macro_export] macro_rules! matches_doesnot { - ($v:expr, = $y:pat, ! $n:pat $(,)?) => - { match $v { $y => true, $n => false } } + ($v:expr, = $($y:pat)|*, ! $($n:pat)|* $(,)?) => + { match $v { $($y)|* => true, $($n)|* => false } } } #[test] @@ -362,6 +362,13 @@ fn matches_doesnot_test() { ! None ) ); + assert!( + matches_doesnot!( + Some(1), + = Some(1) | Some(2), + ! Some(_) | None + ) + ); } pub fn dbgc_helper(file: &'static str, line: u32, -- 2.30.2