diff options
Diffstat (limited to 'src/util.rs')
| -rw-r--r-- | src/util.rs | 15 |
1 files changed, 15 insertions, 0 deletions
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)); + }, + )* + }; + }; +} |
