<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="A compiled match pattern that can match multipe inputs, or return a `Matcher` that matches a single input."><title>Pattern in matchers - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><linkrel="stylesheet"href="../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet"href="../static.files/rustdoc-dd39b87e5fcfba68.css"><metaname="rustdoc-vars"data-root-path="../"data-static-root-path="../static.files/"data-current-crate="matchers"data-themes=""data-resource-suffix=""data-rustdoc-version="1.80.0 (051478957 2024-07-21)"data-channel="1.80.0"data-search-js="search-d52510db62a78183.js"data-settings-js="settings-4313503d2e1961c2.js"><scriptsrc="../static.files/storage-118b08c4c78b968e.js"></script><scriptdefersrc="sidebar-items.js"></script><scriptdefersrc="../static.files/main-20a3ad099b048cf2.js"></script><noscript><linkrel="stylesheet"href="../static.files/noscript-df360f571f6edeae.css"></noscript><linkrel="alternate icon"type="image/png"href="../static.files/favicon-32x32-422f7d1d52889060.png"><linkrel="icon"type="image/svg+xml"href="../static.files/favicon-2c020d218678b618.svg"></head><bodyclass="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle"title="show sidebar"></button></nav><navclass="sidebar"><divclass="sidebar-crate"><h2><ahref="../matchers/index.html">matchers</a><spanclass="version">0.1.0</span></h2></div><h2class="location"><ahref="#">Pattern</a></h2><divclass="sidebar-elems"><section><h3><ahref="#implementations">Methods</a></h3><ulclass="block method"><li><ahref="#method.debug_matches">debug_matches</a></li><li><ahref="#method.display_matches">display_matches</a></li><li><ahref="#method.matches">matches</a></li><li><ahref="#method.new">new</a></li><li><ahref="#method.new_anchored">new_anchored</a></li><li><ahref="#method.read_matches">read_matches</a></li></ul><h3><ahref="#trait-implementations">Trait Implementations</a></h3><ulclass="block trait-implementation"><li><ahref="#impl-Clone-for-Pattern%3CS,+A%3E">Clone</a></li><li><ahref="#impl-Debug-for-Pattern%3CS,+A%3E">Debug</a></li><li><ahref="#impl-FromStr-for-Pattern">FromStr</a></li><li><ahref="#impl-ToMatcher%3C'a,+S%3E-for-Pattern%3CS%3E">ToMatcher<'a, S></a></li><li><ahref="#impl-ToMatcher%3C'a,+S%3E-for-Pattern%3CS,+SparseDFA%3CVec%3Cu8%3E,+S%3E%3E">ToMatcher<'a, S></a></li></ul><h3><ahref="#synthetic-implementations">Auto Trait Implementations</a></h3><ulclass="block synthetic-implementation"><li><ahref="#impl-Freeze-for-Pattern%3CS,+A%3E">Freeze</a></li><li><ahref="#impl-RefUnwindSafe-for-Pattern%3CS,+A%3E">RefUnwindSafe</a></li><li><ahref="#impl-Send-for-Pattern%3CS,+A%3E">Send</a></li><li><ahref="#impl-Sync-for-Pattern%3CS,+A%3E">Sync</a></li><li><ahref="#impl-Unpin-for-Pattern%3CS,+A%3E">Unpin</a></li><li><ahref="#impl-UnwindSafe-for-Pattern%3CS,+A%3E">UnwindSafe</a></li></ul><h3><ahref="#blanket-implementations">Blanket Implementations</a></h3><ulclass="block blanket-implementation"><li><ahref="#impl-Any-for-T">Any</a></li><li><ahref="#impl-Borrow%3CT%3E-for-T">Borrow<T></a></li><li><ahref="#impl-BorrowMut%3CT%3E-for-T">BorrowMut<T></a></li><li><ahref="#impl-From%3CT%3E-for-T">From<T></a></li><li><ahref="#impl-Into%3CU%3E-for-T">Into<U></a></li><li><ahref="#imp
A: <aclass="trait"href="../regex_automata/dfa/trait.DFA.html"title="trait regex_automata::dfa::DFA">DFA</a><ID = S>,</div>{ <spanclass="comment">/* private fields */</span> }</code></pre><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>A compiled match pattern that can match multipe inputs, or return a
<ahref="../struct.Matcher.html"><code>Matcher</code></a> that matches a single input.</p>
</div></details><h2id="implementations"class="section-header">Implementations<ahref="#implementations"class="anchor">§</a></h2><divid="implementations-list"><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Pattern"class="impl"><aclass="src rightside"href="../src/matchers/lib.rs.html#63-127">source</a><ahref="#impl-Pattern"class="anchor">§</a><h3class="code-header">impl <aclass="struct"href="struct.Pattern.html"title="struct matchers::Pattern">Pattern</a></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.new"class="method"><aclass="src rightside"href="../src/matchers/lib.rs.html#89-92">source</a><h4class="code-header">pub fn <ahref="#method.new"class="fn">new</a>(pattern: &<aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><Self, <aclass="struct"href="struct.Error.html"title="struct matchers::Error">Error</a>></h4></section></summary><divclass="docblock"><p>Returns a new <code>Pattern</code> for the given regex, or an error if the regex
<p>The returned <code>Pattern</code> will match occurances of the pattern which start
at <em>any</em> in a byte or character stream — the pattern may be preceded by
any number of non-matching characters. Essentially, it will behave as
though the regular expression started with a <code>.*?</code>, which enables a
match to appear anywhere. If this is not the desired behavior, use
<ahref="struct.Pattern.html#method.new_anchored"title="associated function matchers::Pattern::new_anchored"><code>Pattern::new_anchored</code></a> instead.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.new_anchored"class="method"><aclass="src rightside"href="../src/matchers/lib.rs.html#123-126">source</a><h4class="code-header">pub fn <ahref="#method.new_anchored"class="fn">new_anchored</a>(pattern: &<aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><Self, <aclass="struct"href="struct.Error.html"title="struct matchers::Error">Error</a>></h4></section></summary><divclass="docblock"><p>Returns a new <code>Pattern</code> anchored at the beginning of the input stream,
<p>The returned <code>Pattern</code> will <em>only</em> match an occurence of the pattern in
an input sequence if the first character or byte in the input matches
the pattern. If this is not the desired behavior, use <ahref="struct.Pattern.html#method.new"title="associated function matchers::Pattern::new"><code>Pattern::new</code></a>
Self: for<'a><aclass="trait"href="trait.ToMatcher.html"title="trait matchers::ToMatcher">ToMatcher</a><'a, S>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.matches"class="method"><aclass="src rightside"href="../src/matchers/lib.rs.html#144-146">source</a><h4class="code-header">pub fn <ahref="#method.matches"class="fn">matches</a>(&self, s: &impl <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/convert/trait.AsRef.html"title="trait core::convert::AsRef">AsRef</a><<aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>>) -><aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Returns <code>true</code> if this pattern matches the given string.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.debug_matches"class="method"><aclass="src rightside"href="../src/matchers/lib.rs.html#172-174">source</a><h4class="code-header">pub fn <ahref="#method.debug_matches"class="fn">debug_matches</a>(&self, d: &impl <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html"title="trait core::fmt::Debug">Debug</a>) -><aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Returns <code>true</code> if this pattern matches the formatted output of the given
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.display_matches"class="method"><aclass="src rightside"href="../src/matchers/lib.rs.html#208-210">source</a><h4class="code-header">pub fn <ahref="#method.display_matches"class="fn">display_matches</a>(&self, d: &impl <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Display.html"title="trait core::fmt::Display">Display</a>) -><aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Returns <code>true</code> if this pattern matches the formatted output of the given
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.read_matches"class="method"><aclass="src rightside"href="../src/matchers/lib.rs.html#216-218">source</a><h4class="code-header">pub fn <ahref="#method.read_matches"class="fn">read_matches</a>(&self, io: impl <aclass="trait"href="https://doc.rust-lang.org/1.80.0/std/io/trait.Read.html"title="trait std::io::Read">Read</a>) -><aclass="type"href="https://doc.rust-lang.org/1.80.0/std/io/error/type.Result.html"title="type std::io::error::Result">Result</a><<aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a>></h4></section></summary><divclass="docblock"><p>Returns either a <code>bool</code> indicating whether or not this pattern matches the
A: <aclass="trait"href="../regex_automata/dfa/trait.DFA.html"title="trait regex_automata::dfa::DFA">DFA</a><ID = S> + <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html"title="trait core::fmt::Debug">Debug</a>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.fmt"class="method trait-impl"><aclass="src rightside"href="../src/matchers/lib.rs.html#38">source</a><ahref="#method.fmt"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html#tymethod.fmt"class="fn">fmt</a>(&self, f: &mut <aclass="struct"href="https://doc.rust-lang.org/1.80.0/core/fmt/struct.Formatter.html"title="struct core::fmt::Formatter">Formatter</a><'_>) -><aclass="type"href="https://doc.rust-lang.org/1.80.0/core/fmt/type.Result.html"title="type core::fmt::Result">Result</a></h4></section></summary><divclass='docblock'>Formats the value using the given formatter. <ahref="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-FromStr-for-Pattern"class="impl"><aclass="src rightside"href="../src/matchers/lib.rs.html#129-134">source</a><ahref="#impl-FromStr-for-Pattern"class="anchor">§</a><h3class="code-header">impl <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/str/traits/trait.FromStr.html"title="trait core::str::traits::FromStr">FromStr</a> for <aclass="struct"href="struct.Pattern.html"title="struct matchers::Pattern">Pattern</a></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Err"class="associatedtype trait-impl"><ahref="#associatedtype.Err"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.80.0/core/str/traits/trait.FromStr.html#associatedtype.Err"class="associatedtype">Err</a> = <aclass="struct"href="struct.Error.html"title="struct matchers::Error">Error</a></h4></section></summary><divclass='docblock'>The associated error which can be returned from parsing.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.from_str"class="method trait-impl"><aclass="src rightside"href="../src/matchers/lib.rs.html#131-133">source</a><ahref="#method.from_str"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.80.0/core/str/traits/trait.FromStr.html#tymethod.from_str"class="fn">from_str</a>(s: &<aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><Self, Self::<aclass="associatedtype"href="https://doc.rust-lang.org/1.80.0/core/str/traits/trait.FromStr.html#associatedtype.Err"title="type core::str::traits::FromStr::Err">Err</a>></h4></section></summary><divclass='docblock'>Parses a string <code>s</code> to return a value of this type. <ahref="https://doc.rust-lang.org/1.80.0/core/str/traits/trait.FromStr.html#tymethod.from_str">Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-ToMatcher%3C'a,+S%3E-for-Pattern%3CS%3E"class="impl"><aclass="src rightside"href="../src/matchers/lib.rs.html#345-353">source</a><ahref="#impl-ToMatcher%3C'a,+S%3E-for-Pattern%3CS%3E"class="anchor">§</a><h3class="code-header">impl<'a, S><aclass="trait"href="trait.ToMatcher.html"title="trait matchers::ToMatcher">ToMatcher</a><'a, S> for <aclass="struct"href="struct.Pattern.html"title="struct matchers::Pattern">Pattern</a><S, <aclass="enum"href="../regex_automata/dense_imp/enum.DenseDFA.html"title="enum regex_automata::dense_imp::DenseDFA">DenseDFA</a><<aclass="struct"href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html"title="structalloc::vec::V
<code><ahref="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html"title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-ToOwned-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.80.0/src/alloc/borrow.rs.html#83-85">source</a><ahref="#impl-ToOwned-for-T"class="anchor">§</a><h3class="code-header">impl<T><aclass="trait"href="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html"title="trait alloc::borrow::ToOwned">ToOwned</a> for T<divclass="where">where
T: <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html"title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Owned"class="associatedtype trait-impl"><ahref="#associatedtype.Owned"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html#associatedtype.Owned"class="associatedtype">Owned</a> = T</h4></section></summary><divclass='docblock'>The resulting type after obtaining ownership.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.to_owned"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.80.0/src/alloc/borrow.rs.html#88">source</a><ahref="#method.to_owned"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned"class="fn">to_owned</a>(&self) -> T</h4></section></summary><divclass='docblock'>Creates owned data from borrowed data, usually by cloning. <ahref="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.clone_into"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.80.0/src/alloc/borrow.rs.html#92">source</a><ahref="#method.clone_into"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html#method.clone_into"class="fn">clone_into</a>(&self, target: <aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&mut T</a>)</h4></section></summary><divclass='docblock'>Uses borrowed data to replace owned data, usually by cloning. <ahref="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-TryFrom%3CU%3E-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#805-807">source</a><ahref="#impl-TryFrom%3CU%3E-for-T"class="anchor">§</a><h3class="code-header">impl<T, U><aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><U> for T<divclass="where">where
U: <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Error"class="associatedtype trait-impl"><ahref="#associatedtype.Error"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error"class="associatedtype">Error</a> = <aclass="enum"href="https://doc.rust-lang.org/1.80.0/core/convert/enum.Infallible.html"title="enum core::convert::Infallible">Infallible</a></h4></section></summary><divclass='docblock'>The type returned in the event of a conversion error.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_from"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#812">source</a><ahref="#method.try_from"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#tymethod.try_from"class="fn">try_from</a>(value: U) -><aclass="enum"href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><T, <T as <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><U>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error"title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><divclass='docblock'>Performs the conversion.</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-TryInto%3CU%3E-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#790-792">source</a><ahref="#impl-TryInto%3CU%3E-for-T"class="anchor">§</a><h3class="code-header">impl<T, U><aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryInto.html"title="trait core::convert::TryInto">TryInto</a><U> for T<divclass="where">where
U: <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Error-1"class="associatedtype trait-impl"><ahref="#associatedtype.Error-1"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryInto.html#associatedtype.Error"class="associatedtype">Error</a> = <U as <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error"title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><divclass='docblock'>The type returned in the event of a conversion error.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_into"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#797">source</a><ahref="#method.try_into"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryInto.html#tymethod.try_into"class="fn">try_into</a>(self) -><aclass="enum"href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><U, <U as <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error"title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><divclass='docblock'>Performs the conversion.</div></details></div></details></div><scripttype="text/json"id="notable-traits-data">{"Matcher<'a, S, Self::Automaton>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Matcher.html\" title=\"struct matchers::Matcher\">Matcher</a><'a, S, A></code></h3><pre><code><div class=\"where\">impl<'a, S, A> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.80.0/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for <a class=\"struct\" href=\"struct.Matcher.html\" title=\"struct matchers::Matcher\">Matcher</a><'a, S, A><div class=\"where\">where\n S: <a class=\"trait\" href=\"../regex_automata/state_id/trait.StateID.html\" title=\"trait regex_automata::state_id::StateID\">StateID</a>,\n A: <a class=\"trait\" href=\"../regex_automata/dfa/trait.DFA.html\" title=\"trait regex_automata::dfa::DFA\">DFA</a><ID = S>,</div></div>"}</script></section></div></main></body></html>