| Crates.io | comtains |
| lib.rs | comtains |
| version | 0.1.1 |
| created_at | 2025-10-22 20:22:10.335036+00 |
| updated_at | 2025-10-23 11:30:22.499476+00 |
| description | Zero-allocation byte-set matcher generated at compile time |
| homepage | https://github.com/Coffeeri/comtains |
| repository | https://github.com/Coffeeri/comtains |
| max_upload_size | |
| id | 1896227 |
| size | 30,357 |
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.