memchr
Provides extremely fast (uses SIMD on x86_64, aarch64 and wasm32) routines for 1, 2 or 3 byte search and single substring search.
This package has a good security score with no known vulnerabilities.
Community Reviews
Rock-solid performance primitive with zero learning curve
What impressed me most is how little cognitive overhead it adds to your project. You call `memchr::memchr(b'\n', haystack)` and it just works, blazingly fast. The crate handles SIMD optimization transparently, so you get performance without complexity. I've used it extensively in parsers and text processing pipelines where finding delimiters quickly matters.
The only learning curve comes from understanding which function to use (memchr vs memmem vs memrchr), but the docs make this clear. There's minimal community support needed because there's little to go wrong - it's a focused tool that does one thing exceptionally well.
Best for: Low-level byte searching in parsers, text processors, or performance-critical code where you need SIMD-accelerated delimiter/pattern finding.
Avoid if: You need complex pattern matching, regex capabilities, or Unicode normalization - use regex or bstr instead.
Rock-solid primitive with minimal attack surface and excellent safety
From a security standpoint, the lack of unsafe surface area exposed to users is excellent. The crate uses unsafe internally for SIMD optimizations, but the public API is entirely safe Rust. Input validation is implicit—you're just searching byte slices, so there's no malformed input to worry about. No panics on invalid input, no information leakage through error messages, no crypto to configure incorrectly.
I've used this extensively in parsers and protocol implementations where you need to find delimiters or specific byte sequences. It just works, with predictable performance and zero security gotchas. The deterministic behavior means timing attacks aren't a concern for typical use cases.
Best for: Low-level byte searching in parsers, protocol handlers, and performance-critical text processing where security and reliability matter.
Avoid if: You need complex pattern matching or regex features—this is intentionally minimal for primitive operations only.
Rock-solid primitive with excellent API design and zero-friction integration
Error handling is straightforward - there are no Result types because the operations are infallible. You get `Option<usize>` for position or `None` if not found. The crate provides iterators like `Memchr::new()` for finding all occurrences, which compose beautifully with Rust's iterator chains. Documentation includes clear performance characteristics and SIMD details without overwhelming you.
The zero-config SIMD acceleration is transparent - your code runs faster on supported platforms automatically. I've replaced hand-rolled byte searches with memchr and seen immediate performance wins. It's a textbook example of a low-level crate with high-level ergonomics.
Best for: Performance-critical byte searching in parsers, text processors, or any code doing repeated substring/character searches in byte slices.
Avoid if: You need complex pattern matching or regex features beyond literal byte/substring searches.
Sign in to write a review
Sign In