chiark
/
gitweb
/
~ianmdlvl
/
otter.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1a55b2d
)
utils: Improve matches_doesnot
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 14 Mar 2021 19:31:50 +0000
(19:31 +0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 14 Mar 2021 19:31:50 +0000
(19:31 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/utils.rs
patch
|
blob
|
history
diff --git
a/src/utils.rs
b/src/utils.rs
index e2095f5452157b1766b5fa5c509243133c37e830..4a4a29b60ead32e8e7009b0222402b9286890ada 100644
(file)
--- a/
src/utils.rs
+++ b/
src/utils.rs
@@
-349,8
+349,8
@@
impl<T,U,E,F> IteratorExt<U,E,F> 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,