17 releases (6 stable)

2.0.2 Aug 25, 2018
2.0.1 Nov 30, 2017
2.0.0 Oct 21, 2017
1.0.2 Oct 21, 2017
0.1.3 Jun 14, 2015

#1 in Encoding

Download history 69618/week @ 2018-09-18 84846/week @ 2018-09-25 83216/week @ 2018-10-02 84577/week @ 2018-10-09 84042/week @ 2018-10-16 78192/week @ 2018-10-23 90099/week @ 2018-10-30 95942/week @ 2018-11-06 97620/week @ 2018-11-13 90933/week @ 2018-11-20 81016/week @ 2018-11-27 90320/week @ 2018-12-04 91519/week @ 2018-12-11

266,775 downloads per month
Used in 4,326 crates (63 directly)

Unlicense/MIT

116KB
2.5K SLoC

memchr

The memchr crate provides heavily optimized routines for searching bytes.

Build status Build status

Dual-licensed under MIT or the UNLICENSE.

Documentation

https://docs.rs/memchr

Overview

The memchr function is traditionally provided by libc, however, the performance of memchr can vary significantly depending on the specific implementation of libc that is used. They can range from manually tuned Assembly implementations (like that found in GNU's libc) all the way to non-vectorized C implementations (like that found in MUSL).

To smooth out the differences between implementations of libc, at least on x86_64 for Rust 1.27+, this crate provides its own implementation of memchr that should perform competitively with the one found in GNU's libc. The implementation is in pure Rust and has no dependency on a C compiler or an Assembler.

Additionally, GNU libc also provides an extension, memrchr. This crate provides its own implementation of memrchr as well, on top of memchr2, memchr3, memrchr2 and memrchr3. The difference between memchr and memchr2 is that that memchr2 permits finding all occurrences of two bytes instead of one. Similarly for memchr3.

Compiling without the standard library

memchr links to the standard library by default, but you can disable the use_std feature if you want to use it in a #![no_std] crate:

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

Dependencies

~172KB