<main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><divid="sidebar-button"tabindex="-1"><ahref="../memchr/all.html"title="show sidebar"></a></div><inputclass="search-input"name="search"aria-label="Run search in the documentation"autocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"><divid="help-button"tabindex="-1"><ahref="../help.html"title="help">?</a></div><divid="settings-menu"tabindex="-1"><ahref="../settings.html"title="settings"><imgwidth="22"height="22"alt="Change settings"src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><sectionid="main-content"class="content"><divclass="main-heading"><h1>Crate <aclass="mod"href="#">memchr</a><buttonid="copy-path"title="Copy item path to clipboard"><imgsrc="../static.files/clipboard-7571035ce49a181d.svg"width="19"height="18"alt="Copy item path"></button></h1><spanclass="out-of-band"><aclass="src"href="../src/memchr/lib.rs.html#1-221">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>This library provides heavily optimized routines for string search primitives.</p>
<h2id="example-matching-one-of-three-possible-bytes"><aclass="doc-anchor"href="#example-matching-one-of-three-possible-bytes">§</a>Example: matching one of three possible bytes</h2>
<h2id="example-iterating-over-substring-matches"><aclass="doc-anchor"href="#example-iterating-over-substring-matches">§</a>Example: iterating over substring matches</h2>
<h2id="example-repeating-a-search-for-the-same-needle"><aclass="doc-anchor"href="#example-repeating-a-search-for-the-same-needle">§</a>Example: repeating a search for the same needle</h2>
<p>It may be possible for the overhead of constructing a substring searcher to be
measurable in some workloads. In cases where the same needle is used to search
many haystacks, it is possible to do construction once and thus to avoid it for
subsequent searches. This can be done with a <ahref="memmem/struct.Finder.html"title="struct memchr::memmem::Finder"><code>memmem::Finder</code></a>:</p>
<ahref="memmem/struct.Finder.html#method.into_owned"title="method memchr::memmem::Finder::into_owned"><code>memmem::Finder::into_owned</code></a> API and the
</div></details><h2id="modules"class="section-header">Modules<ahref="#modules"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="mod"href="arch/index.html"title="mod memchr::arch">arch</a></div><divclass="desc docblock-short">A module with low-level architecture dependent routines.</div></li><li><divclass="item-name"><aclass="mod"href="memmem/index.html"title="mod memchr::memmem">memmem</a></div><divclass="desc docblock-short">This module provides forward and reverse substring search routines.</div></li></ul><h2id="structs"class="section-header">Structs<ahref="#structs"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="struct"href="struct.Memchr.html"title="struct memchr::Memchr">Memchr</a></div><divclass="desc docblock-short">An iterator over all occurrences of a single byte in a haystack.</div></li><li><divclass="item-name"><aclass="struct"href="struct.Memchr2.html"title="struct memchr::Memchr2">Memchr2</a></div><divclass="desc docblock-short">An iterator over all occurrences of two possible bytes in a haystack.</div></li><li><divclass="item-name"><aclass="struct"href="struct.Memchr3.html"title="struct memchr::Memchr3">Memchr3</a></div><divclass="desc docblock-short">An iterator over all occurrences of three possible bytes in a haystack.</div></li></ul><h2id="functions"class="section-header">Functions<ahref="#functions"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="fn"href="fn.memchr.html"title="fn memchr::memchr">memchr</a></div><divclass="desc docblock-short">Search for the first occurrence of a byte in a slice.</div></li><li><divclass="item-name"><aclass="fn"href="fn.memchr2.html"title="fn memchr::memchr2">memchr2</a></div><divclass="desc docblock-short">Search for the first occurrence of two possible bytes in a haystack.</div></li><li><divclass="item-name"><aclass="fn"href="fn.memchr2_iter.html"title="fn memchr::memchr2_iter">memchr2_iter</a></div><divclass="desc docblock-short">Returns an iterator over all occurrences of the needles in a haystack.</div></li><li><divclass="item-name"><aclass="fn"href="fn.memchr3.html"title="fn memchr::memchr3">memchr3</a></div><divclass="desc docblock-short">Search for the first occurrence of three possible bytes in a haystack.</div></li><li><divclass="item-name"><aclass="fn"href="fn.memchr3_iter.html"title="fn memchr::memchr3_iter">memchr3_iter</a></div><divclass="desc docblock-short">Returns an iterator over all occurrences of the needles in a haystack.</div></li><li><divclass="item-name"><aclass="fn"href="fn.memchr_iter.html"title="fn memchr::memchr_iter">memchr_iter</a></div><divclass="desc docblock-short">Returns an iterator over all occurrences of the needle in a haystack.</div></li><li><divclass="item-name"><aclass="fn"href="fn.memrchr.html"title="fn memchr::memrchr">memrchr</a></div><divclass="desc docblock-short">Search for the last occurrence of a byte in a slice.</div></li><li><divclass="item-name"><aclass="fn"href="fn.memrchr2.html"title="fn memchr::memrchr2">memrchr2</a></div><divclass="desc docblock-short">Search for the last occurrence of two possible bytes in a haystack.</div></li><li><divclass="item-name"><aclass="fn"href="fn.memrchr2_iter.html"title="fn memchr::memrchr2_iter">memrchr2_iter</a></div><divclass="desc docblock-short">Returns an iterator over all occurrences of the needles in a haystack, in
reverse.</div></li><li><divclass="item-name"><aclass="fn"href="fn.memrchr3.html"title="fn memchr::memrchr3">memrchr3</a></div><divclass="desc docblock-short">Search for the last occurrence of three possible bytes in a haystack.</div></li><li><divclass="item-name"><aclass="fn"href="fn.memrchr3_iter.html"title="fn memchr::memrchr3_iter">memrchr3_iter</a></div><divclass="desc docblock-short">Returns an iterator over all occurrences of the needles in a haystack, in
reverse.</div></li><li><divclass="item-name"><aclass="fn"href="fn.memrchr_iter.html"title="fn memchr::memrchr_iter">memrchr_iter</a></div><divclass="desc docblock-short">Returns an iterator over all occurrences of the needle in a haystack, in