mirror of
https://github.com/fluencelabs/wasmer
synced 2025-05-22 07:01:19 +00:00
286 lines
57 KiB
HTML
286 lines
57 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `AhoCorasickBuilder` struct in crate `aho_corasick`."><meta name="keywords" content="rust, rustlang, rust-lang, AhoCorasickBuilder"><title>aho_corasick::AhoCorasickBuilder - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../aho_corasick/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Struct AhoCorasickBuilder</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.anchored">anchored</a><a href="#method.ascii_case_insensitive">ascii_case_insensitive</a><a href="#method.auto_configure">auto_configure</a><a href="#method.build">build</a><a href="#method.build_with_size">build_with_size</a><a href="#method.byte_classes">byte_classes</a><a href="#method.dense_depth">dense_depth</a><a href="#method.dfa">dfa</a><a href="#method.match_kind">match_kind</a><a href="#method.new">new</a><a href="#method.prefilter">prefilter</a><a href="#method.premultiply">premultiply</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class='location'><a href='index.html'>aho_corasick</a></p><script>window.sidebarCurrent = {name: 'AhoCorasickBuilder', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1447-1451' title='goto source code'>[src]</a></span><span class='in-band'>Struct <a href='index.html'>aho_corasick</a>::<wbr><a class="struct" href=''>AhoCorasickBuilder</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust struct'>pub struct AhoCorasickBuilder { /* fields omitted */ }</pre></div><div class='docblock'><p>A builder for configuring an Aho-Corasick automaton.</p>
|
||
</div><h2 id='methods' class='small-section-header'>Methods<a href='#methods' class='anchor'></a></h2><h3 id='impl' class='impl'><code class='in-band'>impl <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a href='#impl' class='anchor'></a><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1459-1903' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.new' class="method"><code id='new.v'>pub fn <a href='#method.new' class='fnname'>new</a>() -> <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1466-1472' title='goto source code'>[src]</a></h4><div class='docblock'><p>Create a new builder for configuring an Aho-Corasick automaton.</p>
|
||
<p>If you don't need fine grained configuration or aren't sure which knobs
|
||
to set, try using
|
||
<a href="struct.AhoCorasick.html#method.new_auto_configured"><code>AhoCorasick::new_auto_configured</code></a>
|
||
instead.</p>
|
||
</div><h4 id='method.build' class="method"><code id='build.v'>pub fn <a href='#method.build' class='fnname'>build</a><I, P>(&self, patterns: I) -> <a class="struct" href="../aho_corasick/struct.AhoCorasick.html" title="struct aho_corasick::AhoCorasick">AhoCorasick</a> <span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a><Item = P>,<br> P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>, </span></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1497-1509' title='goto source code'>[src]</a></h4><div class='docblock'><p>Build an Aho-Corasick automaton using the configuration set on this
|
||
builder.</p>
|
||
<p>A builder may be reused to create more automatons.</p>
|
||
<p>This method will use the default for representing internal state
|
||
identifiers, which is <code>usize</code>. This guarantees that building the
|
||
automaton will succeed and is generally a good default, but can make
|
||
the size of the automaton 2-8 times bigger than it needs to be,
|
||
depending on your target platform.</p>
|
||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||
<p>Basic usage:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">aho_corasick</span>::<span class="ident">AhoCorasickBuilder</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">patterns</span> <span class="op">=</span> <span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>, <span class="string">"baz"</span>];
|
||
<span class="kw">let</span> <span class="ident">ac</span> <span class="op">=</span> <span class="ident">AhoCorasickBuilder</span>::<span class="ident">new</span>()
|
||
.<span class="ident">build</span>(<span class="ident">patterns</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="number">1</span>), <span class="ident">ac</span>.<span class="ident">find</span>(<span class="string">"xxx bar xxx"</span>).<span class="ident">map</span>(<span class="op">|</span><span class="ident">m</span><span class="op">|</span> <span class="ident">m</span>.<span class="ident">pattern</span>()));</pre></div>
|
||
</div><h4 id='method.build_with_size' class="method"><code id='build_with_size.v'>pub fn <a href='#method.build_with_size' class='fnname'>build_with_size</a><S, I, P>(<br> &self, <br> patterns: I<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../aho_corasick/struct.AhoCorasick.html" title="struct aho_corasick::AhoCorasick">AhoCorasick</a><S>, <a class="struct" href="../aho_corasick/struct.Error.html" title="struct aho_corasick::Error">Error</a>> <span class="where fmt-newline">where<br> S: <a class="trait" href="../aho_corasick/trait.StateID.html" title="trait aho_corasick::StateID">StateID</a>,<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a><Item = P>,<br> P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>, </span></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1559-1577' title='goto source code'>[src]</a></h4><div class='docblock'><p>Build an Aho-Corasick automaton using the configuration set on this
|
||
builder with a specific state identifier representation. This only has
|
||
an effect when the <code>dfa</code> option is enabled.</p>
|
||
<p>Generally, the choices for a state identifier representation are
|
||
<code>u8</code>, <code>u16</code>, <code>u32</code>, <code>u64</code> or <code>usize</code>, with <code>usize</code> being the default.
|
||
The advantage of choosing a smaller state identifier representation
|
||
is that the automaton produced will be smaller. This might be
|
||
beneficial for just generally using less space, or might even allow it
|
||
to fit more of the automaton in your CPU's cache, leading to overall
|
||
better search performance.</p>
|
||
<p>Unlike the standard <code>build</code> method, this can report an error if the
|
||
state identifier representation cannot support the size of the
|
||
automaton.</p>
|
||
<p>Note that the state identifier representation is determined by the
|
||
<code>S</code> type variable. This requires a type hint of some sort, either
|
||
by specifying the return type or using the turbofish, e.g.,
|
||
<code>build_with_size::<u16, _, _>(...)</code>.</p>
|
||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||
<p>Basic usage:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">aho_corasick</span>::{<span class="ident">AhoCorasick</span>, <span class="ident">AhoCorasickBuilder</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">patterns</span> <span class="op">=</span> <span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>, <span class="string">"baz"</span>];
|
||
<span class="kw">let</span> <span class="ident">ac</span>: <span class="ident">AhoCorasick</span><span class="op"><</span><span class="ident">u8</span><span class="op">></span> <span class="op">=</span> <span class="ident">AhoCorasickBuilder</span>::<span class="ident">new</span>()
|
||
.<span class="ident">build_with_size</span>(<span class="ident">patterns</span>)<span class="question-mark">?</span>;
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="number">1</span>), <span class="ident">ac</span>.<span class="ident">find</span>(<span class="string">"xxx bar xxx"</span>).<span class="ident">map</span>(<span class="op">|</span><span class="ident">m</span><span class="op">|</span> <span class="ident">m</span>.<span class="ident">pattern</span>()));</pre></div>
|
||
<p>Or alternatively, with turbofish:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">aho_corasick</span>::<span class="ident">AhoCorasickBuilder</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">patterns</span> <span class="op">=</span> <span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>, <span class="string">"baz"</span>];
|
||
<span class="kw">let</span> <span class="ident">ac</span> <span class="op">=</span> <span class="ident">AhoCorasickBuilder</span>::<span class="ident">new</span>()
|
||
.<span class="ident">build_with_size</span>::<span class="op"><</span><span class="ident">u8</span>, <span class="kw">_</span>, <span class="kw">_</span><span class="op">></span>(<span class="ident">patterns</span>)<span class="question-mark">?</span>;
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="number">1</span>), <span class="ident">ac</span>.<span class="ident">find</span>(<span class="string">"xxx bar xxx"</span>).<span class="ident">map</span>(<span class="op">|</span><span class="ident">m</span><span class="op">|</span> <span class="ident">m</span>.<span class="ident">pattern</span>()));</pre></div>
|
||
</div><h4 id='method.auto_configure' class="method"><code id='auto_configure.v'>pub fn <a href='#method.auto_configure' class='fnname'>auto_configure</a><B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>>(<br> &mut self, <br> patterns: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[B]</a><br>) -> &mut <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1604-1629' title='goto source code'>[src]</a></h4><div class='docblock'><p>Automatically configure the settings on this builder according to the
|
||
patterns that will be used to construct the automaton.</p>
|
||
<p>The idea here is to balance space and time automatically. That is, when
|
||
searching a small number of patterns, this will attempt to use the
|
||
fastest possible configuration since the total space required will be
|
||
small anyway. As the number of patterns grows, this will fall back to
|
||
slower configurations that use less space.</p>
|
||
<p>This is guaranteed to never set <code>match_kind</code>, but any other option may
|
||
be overridden.</p>
|
||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||
<p>Basic usage:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">aho_corasick</span>::<span class="ident">AhoCorasickBuilder</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">patterns</span> <span class="op">=</span> <span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>, <span class="string">"baz"</span>];
|
||
<span class="kw">let</span> <span class="ident">ac</span> <span class="op">=</span> <span class="ident">AhoCorasickBuilder</span>::<span class="ident">new</span>()
|
||
.<span class="ident">auto_configure</span>(<span class="ident">patterns</span>)
|
||
.<span class="ident">build</span>(<span class="ident">patterns</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="number">1</span>), <span class="ident">ac</span>.<span class="ident">find</span>(<span class="string">"xxx bar xxx"</span>).<span class="ident">map</span>(<span class="op">|</span><span class="ident">m</span><span class="op">|</span> <span class="ident">m</span>.<span class="ident">pattern</span>()));</pre></div>
|
||
</div><h4 id='method.match_kind' class="method"><code id='match_kind.v'>pub fn <a href='#method.match_kind' class='fnname'>match_kind</a>(&mut self, kind: <a class="enum" href="../aho_corasick/enum.MatchKind.html" title="enum aho_corasick::MatchKind">MatchKind</a>) -> &mut <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1701-1704' title='goto source code'>[src]</a></h4><div class='docblock'><p>Set the desired match semantics.</p>
|
||
<p>The default is <code>MatchKind::Standard</code>, which corresponds to the match
|
||
semantics supported by the standard textbook description of the
|
||
Aho-Corasick algorithm. Namely, matches are reported as soon as they
|
||
are found. Moreover, this is the only way to get overlapping matches
|
||
or do stream searching.</p>
|
||
<p>The other kinds of match semantics that are supported are
|
||
<code>MatchKind::LeftmostFirst</code> and <code>MatchKind::LeftmostLongest</code>. The former
|
||
corresponds to the match you would get if you were to try to match
|
||
each pattern at each position in the haystack in the same order that
|
||
you give to the automaton. That is, it returns the leftmost match
|
||
corresponding the earliest pattern given to the automaton. The latter
|
||
corresponds to finding the longest possible match among all leftmost
|
||
matches.</p>
|
||
<p>For more details on match semantics, see the
|
||
<a href="enum.MatchKind.html">documentation for <code>MatchKind</code></a>.</p>
|
||
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
||
<p>In these examples, we demonstrate the differences between match
|
||
semantics for a particular set of patterns in a specific order:
|
||
<code>b</code>, <code>abc</code>, <code>abcd</code>.</p>
|
||
<p>Standard semantics:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">aho_corasick</span>::{<span class="ident">AhoCorasickBuilder</span>, <span class="ident">MatchKind</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">patterns</span> <span class="op">=</span> <span class="kw-2">&</span>[<span class="string">"b"</span>, <span class="string">"abc"</span>, <span class="string">"abcd"</span>];
|
||
<span class="kw">let</span> <span class="ident">haystack</span> <span class="op">=</span> <span class="string">"abcd"</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">ac</span> <span class="op">=</span> <span class="ident">AhoCorasickBuilder</span>::<span class="ident">new</span>()
|
||
.<span class="ident">match_kind</span>(<span class="ident">MatchKind</span>::<span class="ident">Standard</span>) <span class="comment">// default, not necessary</span>
|
||
.<span class="ident">build</span>(<span class="ident">patterns</span>);
|
||
<span class="kw">let</span> <span class="ident">mat</span> <span class="op">=</span> <span class="ident">ac</span>.<span class="ident">find</span>(<span class="ident">haystack</span>).<span class="ident">expect</span>(<span class="string">"should have a match"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">"b"</span>, <span class="kw-2">&</span><span class="ident">haystack</span>[<span class="ident">mat</span>.<span class="ident">start</span>()..<span class="ident">mat</span>.<span class="ident">end</span>()]);</pre></div>
|
||
<p>Leftmost-first semantics:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">aho_corasick</span>::{<span class="ident">AhoCorasickBuilder</span>, <span class="ident">MatchKind</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">patterns</span> <span class="op">=</span> <span class="kw-2">&</span>[<span class="string">"b"</span>, <span class="string">"abc"</span>, <span class="string">"abcd"</span>];
|
||
<span class="kw">let</span> <span class="ident">haystack</span> <span class="op">=</span> <span class="string">"abcd"</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">ac</span> <span class="op">=</span> <span class="ident">AhoCorasickBuilder</span>::<span class="ident">new</span>()
|
||
.<span class="ident">match_kind</span>(<span class="ident">MatchKind</span>::<span class="ident">LeftmostFirst</span>)
|
||
.<span class="ident">build</span>(<span class="ident">patterns</span>);
|
||
<span class="kw">let</span> <span class="ident">mat</span> <span class="op">=</span> <span class="ident">ac</span>.<span class="ident">find</span>(<span class="ident">haystack</span>).<span class="ident">expect</span>(<span class="string">"should have a match"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">"abc"</span>, <span class="kw-2">&</span><span class="ident">haystack</span>[<span class="ident">mat</span>.<span class="ident">start</span>()..<span class="ident">mat</span>.<span class="ident">end</span>()]);</pre></div>
|
||
<p>Leftmost-longest semantics:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">aho_corasick</span>::{<span class="ident">AhoCorasickBuilder</span>, <span class="ident">MatchKind</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">patterns</span> <span class="op">=</span> <span class="kw-2">&</span>[<span class="string">"b"</span>, <span class="string">"abc"</span>, <span class="string">"abcd"</span>];
|
||
<span class="kw">let</span> <span class="ident">haystack</span> <span class="op">=</span> <span class="string">"abcd"</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">ac</span> <span class="op">=</span> <span class="ident">AhoCorasickBuilder</span>::<span class="ident">new</span>()
|
||
.<span class="ident">match_kind</span>(<span class="ident">MatchKind</span>::<span class="ident">LeftmostLongest</span>)
|
||
.<span class="ident">build</span>(<span class="ident">patterns</span>);
|
||
<span class="kw">let</span> <span class="ident">mat</span> <span class="op">=</span> <span class="ident">ac</span>.<span class="ident">find</span>(<span class="ident">haystack</span>).<span class="ident">expect</span>(<span class="string">"should have a match"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">"abcd"</span>, <span class="kw-2">&</span><span class="ident">haystack</span>[<span class="ident">mat</span>.<span class="ident">start</span>()..<span class="ident">mat</span>.<span class="ident">end</span>()]);</pre></div>
|
||
</div><h4 id='method.anchored' class="method"><code id='anchored.v'>pub fn <a href='#method.anchored' class='fnname'>anchored</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1742-1745' title='goto source code'>[src]</a></h4><div class='docblock'><p>Enable anchored mode, which requires all matches to start at the
|
||
first position in a haystack.</p>
|
||
<p>This option is disabled by default.</p>
|
||
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
||
<p>Basic usage:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">aho_corasick</span>::<span class="ident">AhoCorasickBuilder</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">patterns</span> <span class="op">=</span> <span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>];
|
||
<span class="kw">let</span> <span class="ident">haystack</span> <span class="op">=</span> <span class="string">"foobar"</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">ac</span> <span class="op">=</span> <span class="ident">AhoCorasickBuilder</span>::<span class="ident">new</span>()
|
||
.<span class="ident">anchored</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">build</span>(<span class="ident">patterns</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1</span>, <span class="ident">ac</span>.<span class="ident">find_iter</span>(<span class="ident">haystack</span>).<span class="ident">count</span>());</pre></div>
|
||
<p>When searching for overlapping matches, all matches that start at
|
||
the beginning of a haystack will be reported:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">aho_corasick</span>::<span class="ident">AhoCorasickBuilder</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">patterns</span> <span class="op">=</span> <span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"foofoo"</span>];
|
||
<span class="kw">let</span> <span class="ident">haystack</span> <span class="op">=</span> <span class="string">"foofoo"</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">ac</span> <span class="op">=</span> <span class="ident">AhoCorasickBuilder</span>::<span class="ident">new</span>()
|
||
.<span class="ident">anchored</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">build</span>(<span class="ident">patterns</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">2</span>, <span class="ident">ac</span>.<span class="ident">find_overlapping_iter</span>(<span class="ident">haystack</span>).<span class="ident">count</span>());
|
||
<span class="comment">// A non-anchored search would return 3 matches.</span></pre></div>
|
||
</div><h4 id='method.ascii_case_insensitive' class="method"><code id='ascii_case_insensitive.v'>pub fn <a href='#method.ascii_case_insensitive' class='fnname'>ascii_case_insensitive</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1774-1780' title='goto source code'>[src]</a></h4><div class='docblock'><p>Enable ASCII-aware case insensitive matching.</p>
|
||
<p>When this option is enabled, searching will be performed without
|
||
respect to case for ASCII letters (<code>a-z</code> and <code>A-Z</code>) only.</p>
|
||
<p>Enabling this option does not change the search algorithm, but it may
|
||
increase the size of the automaton.</p>
|
||
<p><strong>NOTE:</strong> In the future, support for full Unicode case insensitivity
|
||
may be added, but ASCII case insensitivity is comparatively much
|
||
simpler to add.</p>
|
||
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
||
<p>Basic usage:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">aho_corasick</span>::<span class="ident">AhoCorasickBuilder</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">patterns</span> <span class="op">=</span> <span class="kw-2">&</span>[<span class="string">"FOO"</span>, <span class="string">"bAr"</span>, <span class="string">"BaZ"</span>];
|
||
<span class="kw">let</span> <span class="ident">haystack</span> <span class="op">=</span> <span class="string">"foo bar baz"</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">ac</span> <span class="op">=</span> <span class="ident">AhoCorasickBuilder</span>::<span class="ident">new</span>()
|
||
.<span class="ident">ascii_case_insensitive</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">build</span>(<span class="ident">patterns</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">3</span>, <span class="ident">ac</span>.<span class="ident">find_iter</span>(<span class="ident">haystack</span>).<span class="ident">count</span>());</pre></div>
|
||
</div><h4 id='method.dense_depth' class="method"><code id='dense_depth.v'>pub fn <a href='#method.dense_depth' class='fnname'>dense_depth</a>(&mut self, depth: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> &mut <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1800-1803' title='goto source code'>[src]</a></h4><div class='docblock'><p>Set the limit on how many NFA states use a dense representation for
|
||
their transitions.</p>
|
||
<p>A dense representation uses more space, but supports faster access to
|
||
transitions at search time. Thus, this setting permits the control of a
|
||
space vs time trade off when using the NFA variant of Aho-Corasick.</p>
|
||
<p>This limit is expressed in terms of the depth of a state, i.e., the
|
||
number of transitions from the starting state of the NFA. The idea is
|
||
that most of the time searching will be spent near the starting state
|
||
of the automaton, so states near the start state should use a dense
|
||
representation. States further away from the start state would then use
|
||
a sparse representation, which uses less space but is slower to access
|
||
transitions at search time.</p>
|
||
<p>By default, this is set to a low but non-zero number.</p>
|
||
<p>This setting has no effect if the <code>dfa</code> option is enabled.</p>
|
||
</div><h4 id='method.dfa' class="method"><code id='dfa.v'>pub fn <a href='#method.dfa' class='fnname'>dfa</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1826-1829' title='goto source code'>[src]</a></h4><div class='docblock'><p>Compile the standard Aho-Corasick automaton into a deterministic finite
|
||
automaton (DFA).</p>
|
||
<p>When this is disabled (which is the default), then a non-deterministic
|
||
finite automaton (NFA) is used instead.</p>
|
||
<p>The main benefit to a DFA is that it can execute searches more quickly
|
||
than a DFA (perhaps 2-4 times as fast). The main drawback is that the
|
||
DFA uses more space and can take much longer to build.</p>
|
||
<p>Enabling this option does not change the time complexity for
|
||
constructing the Aho-Corasick automaton (which is <code>O(p)</code> where
|
||
<code>p</code> is the total number of patterns being compiled). Enabling this
|
||
option does however reduce the time complexity of non-overlapping
|
||
searches from <code>O(n + p)</code> to <code>O(n)</code>, where <code>n</code> is the length of the
|
||
haystack.</p>
|
||
<p>In general, it's a good idea to enable this if you're searching a
|
||
small number of fairly short patterns (~1000), or if you want the
|
||
fastest possible search without regard to compilation time or space
|
||
usage.</p>
|
||
</div><h4 id='method.prefilter' class="method"><code id='prefilter.v'>pub fn <a href='#method.prefilter' class='fnname'>prefilter</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1840-1843' title='goto source code'>[src]</a></h4><div class='docblock'><p>Enable heuristic prefilter optimizations.</p>
|
||
<p>When enabled, searching will attempt to quickly skip to match
|
||
candidates using specialized literal search routines. A prefilter
|
||
cannot always be used, and is generally treated as a heuristic. It
|
||
can be useful to disable this if the prefilter is observed to be
|
||
sub-optimal for a particular workload.</p>
|
||
<p>This is enabled by default.</p>
|
||
</div><h4 id='method.byte_classes' class="method"><code id='byte_classes.v'>pub fn <a href='#method.byte_classes' class='fnname'>byte_classes</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1871-1874' title='goto source code'>[src]</a></h4><div class='docblock'><p>Shrink the size of the transition alphabet by mapping bytes to their
|
||
equivalence classes. This only has an effect when the <code>dfa</code> option is
|
||
enabled.</p>
|
||
<p>When enabled, each a DFA will use a map from all possible bytes
|
||
to their corresponding equivalence class. Each equivalence class
|
||
represents a set of bytes that does not discriminate between a match
|
||
and a non-match in the DFA. For example, the patterns <code>bar</code> and <code>baz</code>
|
||
have at least five equivalence classes: singleton sets of <code>b</code>, <code>a</code>, <code>r</code>
|
||
and <code>z</code>, and a final set that contains every other byte.</p>
|
||
<p>The advantage of this map is that the size of the transition table can
|
||
be reduced drastically from <code>#states * 256 * sizeof(id)</code> to
|
||
<code>#states * k * sizeof(id)</code> where <code>k</code> is the number of equivalence
|
||
classes. As a result, total space usage can decrease substantially.
|
||
Moreover, since a smaller alphabet is used, compilation becomes faster
|
||
as well.</p>
|
||
<p>The disadvantage of this map is that every byte searched must be
|
||
passed through this map before it can be used to determine the next
|
||
transition. This has a small match time performance cost. However, if
|
||
the DFA is otherwise very large without byte classes, then using byte
|
||
classes can greatly improve memory locality and thus lead to better
|
||
overall performance.</p>
|
||
<p>This option is enabled by default.</p>
|
||
</div><h4 id='method.premultiply' class="method"><code id='premultiply.v'>pub fn <a href='#method.premultiply' class='fnname'>premultiply</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1899-1902' title='goto source code'>[src]</a></h4><div class='docblock'><p>Premultiply state identifiers in the transition table. This only has
|
||
an effect when the <code>dfa</code> option is enabled.</p>
|
||
<p>When enabled, state identifiers are premultiplied to point to their
|
||
corresponding row in the transition table. That is, given the <code>i</code>th
|
||
state, its corresponding premultiplied identifier is <code>i * k</code> where <code>k</code>
|
||
is the alphabet size of the automaton. (The alphabet size is at most
|
||
256, but is in practice smaller if byte classes is enabled.)</p>
|
||
<p>When state identifiers are not premultiplied, then the identifier of
|
||
the <code>i</code>th state is <code>i</code>.</p>
|
||
<p>The advantage of premultiplying state identifiers is that is saves a
|
||
multiplication instruction per byte when searching with a DFA. This has
|
||
been observed to lead to a 20% performance benefit in micro-benchmarks.</p>
|
||
<p>The primary disadvantage of premultiplying state identifiers is
|
||
that they require a larger integer size to represent. For example,
|
||
if the DFA has 200 states, then its premultiplied form requires 16
|
||
bits to represent every possible state identifier, where as its
|
||
non-premultiplied form only requires 8 bits.</p>
|
||
<p>This option is enabled by default.</p>
|
||
</div></div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-Default' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a href='#impl-Default' class='anchor'></a><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1453-1457' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.default' class="method hidden"><code id='default.v'>fn <a href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -> <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1454-1456' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Returns the "default value" for a type. <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></p>
|
||
</div></div><h3 id='impl-Clone' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a href='#impl-Clone' class='anchor'></a><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1446' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.clone' class="method hidden"><code id='clone.v'>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&self) -> <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1446' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||
</div><h4 id='method.clone_from' class="method hidden"><code id='clone_from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/clone.rs.html#131-133' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
|
||
</div></div><h3 id='impl-Debug' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a href='#impl-Debug' class='anchor'></a><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1446' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fmt' class="method hidden"><code id='fmt.v'>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class='srclink' href='../src/aho_corasick/ahocorasick.rs.html#1446' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||
</div></div></div><h2 id='synthetic-implementations' class='small-section-header'>Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a></h2><div id='synthetic-implementations-list'><h3 id='impl-Sync' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a href='#impl-Sync' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Send' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a href='#impl-Send' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Unpin' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a href='#impl-Unpin' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-UnwindSafe' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a href='#impl-UnwindSafe' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-RefUnwindSafe' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../aho_corasick/struct.AhoCorasickBuilder.html" title="struct aho_corasick::AhoCorasickBuilder">AhoCorasickBuilder</a></code><a href='#impl-RefUnwindSafe' class='anchor'></a></h3><div class='impl-items'></div></div><h2 id='blanket-implementations' class='small-section-header'>Blanket Implementations<a href='#blanket-implementations' class='anchor'></a></h2><div id='blanket-implementations-list'><h3 id='impl-Into%3CU%3E' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href='#impl-Into%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#543-548' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.into' class="method hidden"><code id='into.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -> U</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#545-547' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id='impl-ToOwned' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, </span></code><a href='#impl-ToOwned' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#81-92' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Owned' class="type"><code id='Owned.t'>type <a href='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned' class="type">Owned</a> = T</code></h4><div class='docblock'><p>The resulting type after obtaining ownership.</p>
|
||
</div><h4 id='method.to_owned' class="method hidden"><code id='to_owned.v'>fn <a href='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned' class='fnname'>to_owned</a>(&self) -> T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#85-87' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
|
||
</div><h4 id='method.clone_into' class="method hidden"><code id='clone_into.v'>fn <a href='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into' class='fnname'>clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T)</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#89-91' title='goto source code'>[src]</a></h4><div class='stability hidden'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code>)</summary><p>recently added</p>
|
||
</details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
|
||
</div></div><h3 id='impl-From%3CT%3E' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href='#impl-From%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#552-554' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from' class="method hidden"><code id='from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -> T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#553' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id='impl-TryFrom%3CU%3E' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href='#impl-TryFrom%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#571-577' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><code id='Error.t'>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||
</div><h4 id='method.try_from' class="method hidden"><code id='try_from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#574-576' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id='impl-TryInto%3CU%3E' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href='#impl-TryInto%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#559-566' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><code id='Error.t-1'>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||
</div><h4 id='method.try_into' class="method hidden"><code id='try_into.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#563-565' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id='impl-BorrowMut%3CT%3E' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href='#impl-BorrowMut%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method hidden"><code id='borrow_mut.v'>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut' class='fnname'>borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#219' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||
</div></div><h3 id='impl-Borrow%3CT%3E' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href='#impl-Borrow%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#213-215' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow' class="method hidden"><code id='borrow.v'>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||
</div></div><h3 id='impl-Any' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href='#impl-Any' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#100-102' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.type_id' class="method hidden"><code id='type_id.v'>fn <a href='https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id' class='fnname'>type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#101' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "aho_corasick";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html> |