From a7858cd77151430b3fab0bcdcacdc14375f77980 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sun, 12 Jan 2020 18:01:18 +0100 Subject: initial implementation done --- src/util.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/util.rs') diff --git a/src/util.rs b/src/util.rs index e69de29..809287f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -0,0 +1,15 @@ +#[macro_export] +macro_rules! parse_match { + ( $matchee:expr, $pos:expr, $map:expr, $bytes:expr, $name:expr, $(($pattern:pat, $type:ty, $variant:expr)),* ) => { + match $matchee { + $( + $pattern => { + let value: $type; + + $pos = $pos + value.parse(&$bytes[($pos)..]); + $map.insert($name, $variant(value)); + }, + )* + }; + }; +} -- cgit v1.2.3