Thanks to visit codestin.com
Credit goes to lib.rs

#search #byte

no-std memchr-rs

Fast memchr and memchr2 implementations in Rust

3 stable releases

Uses new Rust 2024

1.0.11 Dec 21, 2025
1.0.0 Dec 17, 2025

#1145 in Text processing

Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

242 downloads per month

MIT license

27KB
568 lines

memchr-rs

Fast memchr and memchr2 implementations in Rust.

Originally extracted from microsoft/edit under the MIT license.

Usage

Add the following crate to your Cargo.toml and enable either/both the memchr and memchr2 feature as needed:

[dependencies]
memchr-rs = { version = "1", features = ["memchr"] }

Then, use the provided APIs to perform fast byte searches:

use memchr_rs::memchr;

fn main() {
    let haystack = b"Hello, world!";
    let index = memchr(b'w', haystack, 0);
    assert_eq!(index, 7);
    println!("Found 'w' at position: {index}");
}

For no_std environments, disable the default-features:

[dependencies]
memchr-rs = { version = "1", default-features = false, features = ["memchr"] }

No runtime deps

Features