22 releases (11 stable)

2.2.0 Feb 12, 2019
2.1.2 Dec 11, 2018
2.1.1 Oct 29, 2018
2.0.1 Nov 30, 2017
0.1.3 Jun 14, 2015

#1 in Internationalization (i18n)

Download history 73109/week @ 2018-12-20 73183/week @ 2018-12-27 101385/week @ 2019-01-03 103006/week @ 2019-01-10 119678/week @ 2019-01-17 111507/week @ 2019-01-24 111159/week @ 2019-01-31 124602/week @ 2019-02-07 126388/week @ 2019-02-14 126492/week @ 2019-02-21 129676/week @ 2019-02-28 125165/week @ 2019-03-07 117536/week @ 2019-03-14 108771/week @ 2019-03-21 113586/week @ 2019-03-28

497,521 downloads per month
Used in 5,669 crates (82 directly)

Unlicense/MIT

120KB
3K 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 }

On x86 platforms, when the use_std feature is disabled, the SSE2 implementation of memchr will be used in compilers that support it. When use_std is enabled, the AVX implementation of memchr will be used if the CPU is determined to support it at runtime.

Dependencies

  • optional libc 0.2.18