#byte #pattern #slice #matching #language #extension

macro match_bytes

A language extension for matching byte patterns in slices of bytes

1 unstable release

0.1.0 Dec 31, 2022

#2125 in Procedural macros

MIT/Apache

34KB
197 lines

matches_bytes

matches_bytes is a library for matching byte patterns in slices of bytes. matches_bytes is inspired by Erlang's bit sytax.

Example

    let bytes = [0, 0, 0, 1, 0, 0, 0, 0];
    match_bytes!([prefix: u32 / be, rest @ ..] = &bytes);

    assert_eq!(prefix, 1);
    assert_eq!(*rest, [0, 0, 0, 0]);

Dependencies

~1.5MB
~37K SLoC