| Crates.io | comtains_macros |
| lib.rs | comtains_macros |
| version | 0.1.1 |
| created_at | 2025-10-22 20:21:51.639306+00 |
| updated_at | 2025-10-23 11:29:28.647835+00 |
| description | Procedural macro that builds comtains byte-set matchers |
| homepage | https://github.com/Coffeeri/comtains |
| repository | https://github.com/Coffeeri/comtains |
| max_upload_size | |
| id | 1896226 |
| size | 14,204 |
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 comtains::{byte_set, ByteSet};
const HTTP_METHODS: ByteSet = byte_set![b"GET", b"POST", b"PUT", b"PATCH"];
assert!(HTTP_METHODS.contains(b"GET"));
assert!(!HTTP_METHODS.contains(b"DELETE"));
match ladder that compares candidate[depth], short-circuiting on the first mismatch.