comtains
comtains expands static byte sequences into zero-allocation matchers at compile time. The byte_set! macro emits a branch-ordered decision tree, keeping membership checks to a handful of predictable instructions—ideal for tight opcode dispatchers or protocol parsers.
use ;
const HTTP_METHODS: ByteSet = byte_set!;
assert!;
assert!;
How it works
- All inputs are parsed at macro expansion time into a trie that shares common prefixes.
- Each edge records how many sequences traverse it; siblings are sorted by descending weight to probe common paths first.
- The macro generates a nested
matchladder that comparescandidate[depth], short-circuiting on the first mismatch. - Debug metadata is emitted alongside the matcher so tests and benchmarks can assert branch ordering or inspect the trie layout.