diff options
| author | Max Audron <audron@cocaine.farm> | 2020-01-12 18:01:18 +0100 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2020-01-13 19:13:05 +0100 |
| commit | a7858cd77151430b3fab0bcdcacdc14375f77980 (patch) | |
| tree | b6f3d72f1c6e32b2d32f33ca3ce56a765a595d86 /src/util.rs | |
| parent | init (diff) | |
initial implementation done
Diffstat (limited to '')
| -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)); + }, + )* + }; + }; +} |
