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:
45ddb33
)
utils: provide matches_doesnot
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 7 Mar 2021 22:16:24 +0000
(22:16 +0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 7 Mar 2021 22:16:24 +0000
(22:16 +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 a7ab450445867c2e156dbba6661f03b785271104..6169c1629a92a7998f69a4a339df26c80f0b5e84 100644
(file)
--- a/
src/utils.rs
+++ b/
src/utils.rs
@@
-353,6
+353,16
@@
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 } }
+}
+
+#[test]
+fn matches_doesnot_test() {
+ assert!( matches_doesnot!( Some(42); Some(_), ! None) );
+}
+
#[macro_export]
macro_rules! dbgc {
// NOTE: We cannot use `concat!` to make a static string as a format argument