<!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="The span offsets of capturing groups after a match has been found."><title>Captures in regex_automata::util::captures - Rust</title><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><linkrel="stylesheet"href="../../../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet"href="../../../static.files/rustdoc-5bc39a1768837dd0.css"><metaname="rustdoc-vars"data-root-path="../../../"data-static-root-path="../../../static.files/"data-current-crate="regex_automata"data-themes=""data-resource-suffix=""data-rustdoc-version="1.77.2 (25ef9e3d8 2024-04-09)"data-channel="1.77.2"data-search-js="search-dd67cee4cfa65049.js"data-settings-js="settings-4313503d2e1961c2.js"><scriptsrc="../../../static.files/storage-4c98445ec4002617.js"></script><scriptdefersrc="sidebar-items.js"></script><scriptdefersrc="../../../static.files/main-48f368f3872407c8.js"></script><noscript><linkrel="stylesheet"href="../../../static.files/noscript-04d5337699b92874.css"></noscript><linkrel="alternate icon"type="image/png"href="../../../static.files/favicon-16x16-8b506e7a72182f1c.png"><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="../../../regex_automata/index.html">regex_automata</a><spanclass="version">0.4.6</span></h2></div><h2class="location"><ahref="#">Captures</a></h2><divclass="sidebar-elems"><section><h3><ahref="#implementations">Methods</a></h3><ulclass="block method"><li><ahref="#method.all">all</a></li><li><ahref="#method.clear">clear</a></li><li><ahref="#method.empty">empty</a></li><li><ahref="#method.extract">extract</a></li><li><ahref="#method.extract_bytes">extract_bytes</a></li><li><ahref="#method.get_group">get_group</a></li><li><ahref="#method.get_group_by_name">get_group_by_name</a></li><li><ahref="#method.get_match">get_match</a></li><li><ahref="#method.group_info">group_info</a></li><li><ahref="#method.group_len">group_len</a></li><li><ahref="#method.interpolate_bytes">interpolate_bytes</a></li><li><ahref="#method.interpolate_bytes_into">interpolate_bytes_into</a></li><li><ahref="#method.interpolate_string">interpolate_string</a></li><li><ahref="#method.interpolate_string_into">interpolate_string_into</a></li><li><ahref="#method.is_match">is_match</a></li><li><ahref="#method.iter">iter</a></li><li><ahref="#method.matches">matches</a></li><li><ahref="#method.pattern">pattern</a></li><li><ahref="#method.set_pattern">set_pattern</a></li><li><ahref="#method.slots">slots</a></li><li><ahref="#method.slots_mut">slots_mut</a></li></ul><h3><ahref="#trait-implementations">Trait Implementations</a></h3><ulclass="block trait-implementation"><li><ahref="#impl-Clone-for-Captures">Clone</a></li><li><ahref="#impl-Debug-for-Captures">Debug</a></li></ul><h3><ahref="#synthetic-implementations">Auto Trait Impl
<main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><divid="sidebar-button"tabindex="-1"><ahref="../../../regex_automata/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>Struct <ahref="../../index.html">regex_automata</a>::<wbr><ahref="../index.html">util</a>::<wbr><ahref="index.html">captures</a>::<wbr><aclass="struct"href="#">Captures</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/regex_automata/util/captures.rs.html#130-173">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><preclass="rust item-decl"><code>pub struct Captures { <spanclass="comment">/* private fields */</span> }</code></pre><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>The span offsets of capturing groups after a match has been found.</p>
<p>This type represents the output of regex engines that can report the
offsets at which capturing groups matches or “submatches” occur. For
example, the <ahref="../../nfa/thompson/pikevm/struct.PikeVM.html"title="struct regex_automata::nfa::thompson::pikevm::PikeVM"><code>PikeVM</code></a>. When a match
occurs, it will at minimum contain the <ahref="../../struct.PatternID.html"title="struct regex_automata::PatternID"><code>PatternID</code></a> of the pattern that
matched. Depending upon how it was constructed, it may also contain the
start/end offsets of the entire match of the pattern and the start/end
offsets of each capturing group that participated in the match.</p>
<p>Values of this type are always created for a specific <ahref="struct.GroupInfo.html"title="struct regex_automata::util::captures::GroupInfo"><code>GroupInfo</code></a>. It is
unspecified behavior to use a <code>Captures</code> value in a search with any regex
engine that has a different <code>GroupInfo</code> than the one the <code>Captures</code> were
<p>There are three constructors for this type that control what kind of
information is available upon a match:</p>
<ul>
<li><ahref="struct.Captures.html#method.all"title="associated function regex_automata::util::captures::Captures::all"><code>Captures::all</code></a>: Will store overall pattern match offsets in addition
to the offsets of capturing groups that participated in the match.</li>
<li><ahref="struct.Captures.html#method.matches"title="associated function regex_automata::util::captures::Captures::matches"><code>Captures::matches</code></a>: Will store only the overall pattern
match offsets. The offsets of capturing groups (even ones that participated
in the match) are not available.</li>
<li><ahref="struct.Captures.html#method.empty"title="associated function regex_automata::util::captures::Captures::empty"><code>Captures::empty</code></a>: Will only store the pattern ID that matched. No
match offsets are available at all.</li>
</ul>
<p>If you aren’t sure which to choose, then pick the first one. The first one
<p>It is worth pointing out that this type is not coupled to any one specific
regex engine. Instead, its coupling is with <ahref="struct.GroupInfo.html"title="struct regex_automata::util::captures::GroupInfo"><code>GroupInfo</code></a>, which is the
thing that is responsible for mapping capturing groups to “slot” offsets.
Slot offsets are indices into a single sequence of memory at which matching
haystack offsets for the corresponding group are written by regex engines.</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-Captures"class="impl"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#175-1005">source</a><ahref="#impl-Captures"class="anchor">§</a><h3class="code-header">impl <aclass="struct"href="struct.Captures.html"title="struct regex_automata::util::captures::Captures">Captures</a></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.all"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#215-218">source</a><h4class="code-header">pub fn <ahref="#method.all"class="fn">all</a>(group_info: <aclass="struct"href="struct.GroupInfo.html"title="struct regex_automata::util::captures::GroupInfo">GroupInfo</a>) -><aclass="struct"href="struct.Captures.html"title="struct regex_automata::util::captures::Captures">Captures</a></h4></section></summary><divclass="docblock"><p>Create new storage for the offsets of all matching capturing groups.</p>
<p>This routine provides the most information for matches—namely, the
spans of matching capturing groups—but also requires the regex search
routines to do the most work.</p>
<p>It is unspecified behavior to use the returned <code>Captures</code> value in a
search with a <code>GroupInfo</code> other than the one that is provided to this
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.matches"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#256-262">source</a><h4class="code-header">pub fn <ahref="#method.matches"class="fn">matches</a>(group_info: <aclass="struct"href="struct.GroupInfo.html"title="struct regex_automata::util::captures::GroupInfo">GroupInfo</a>) -><aclass="struct"href="struct.Captures.html"title="struct regex_automata::util::captures::Captures">Captures</a></h4></section></summary><divclass="docblock"><p>Create new storage for only the full match spans of a pattern. This
does not include any capturing group offsets.</p>
<p>It is unspecified behavior to use the returned <code>Captures</code> value in a
search with a <code>GroupInfo</code> other than the one that is provided to this
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.empty"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#301-303">source</a><h4class="code-header">pub fn <ahref="#method.empty"class="fn">empty</a>(group_info: <aclass="struct"href="struct.GroupInfo.html"title="struct regex_automata::util::captures::GroupInfo">GroupInfo</a>) -><aclass="struct"href="struct.Captures.html"title="struct regex_automata::util::captures::Captures">Captures</a></h4></section></summary><divclass="docblock"><p>Create new storage for only tracking which pattern matched. No offsets
are stored at all.</p>
<p>It is unspecified behavior to use the returned <code>Captures</code> value in a
search with a <code>GroupInfo</code> other than the one that is provided to this
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.is_match"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#331-333">source</a><h4class="code-header">pub fn <ahref="#method.is_match"class="fn">is_match</a>(&self) -><aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Returns true if and only if this capturing group represents a match.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.pattern"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#369-371">source</a><h4class="code-header">pub fn <ahref="#method.pattern"class="fn">pattern</a>(&self) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../../struct.PatternID.html"title="struct regex_automata::PatternID">PatternID</a>></h4></section></summary><divclass="docblock"><p>Returns the identifier of the pattern that matched when this
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.get_match"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#398-400">source</a><h4class="code-header">pub fn <ahref="#method.get_match"class="fn">get_match</a>(&self) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../../struct.Match.html"title="struct regex_automata::Match">Match</a>></h4></section></summary><divclass="docblock"><p>Returns the pattern ID and the span of the match, if one occurred.</p>
<p>This always returns <code>None</code> when <code>Captures</code> was created with
<ahref="struct.Captures.html#method.empty"title="associated function regex_automata::util::captures::Captures::empty"><code>Captures::empty</code></a>, even if a match was found.</p>
<p>If this routine returns a non-<code>None</code> value, then <code>is_match</code> is
guaranteed to return <code>true</code> and <code>pattern</code> is also guaranteed to return
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.get_group"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#454-467">source</a><h4class="code-header">pub fn <ahref="#method.get_group"class="fn">get_group</a>(&self, index: <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.usize.html">usize</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../../struct.Span.html"title="struct regex_automata::Span">Span</a>></h4></section></summary><divclass="docblock"><p>Returns the span of a capturing group match corresponding to the group
index given, only if both the overall pattern matched and the capturing
group participated in that match.</p>
<p>This returns <code>None</code> if <code>index</code> is invalid. <code>index</code> is valid if and only
if it’s less than <ahref="struct.Captures.html#method.group_len"title="method regex_automata::util::captures::Captures::group_len"><code>Captures::group_len</code></a> for the matching pattern.</p>
<p>This always returns <code>None</code> when <code>Captures</code> was created with
<ahref="struct.Captures.html#method.empty"title="associated function regex_automata::util::captures::Captures::empty"><code>Captures::empty</code></a>, even if a match was found. This also always
returns <code>None</code> for any <code>index > 0</code> when <code>Captures</code> was created with
<ahref="struct.Captures.html#method.matches"title="associated function regex_automata::util::captures::Captures::matches"><code>Captures::matches</code></a>.</p>
<p>If this routine returns a non-<code>None</code> value, then <code>is_match</code> is
guaranteed to return <code>true</code>, <code>pattern</code> is guaranteed to return a
non-<code>None</code> value and <code>get_match</code> is guaranteed to return a non-<code>None</code>
value.</p>
<p>By convention, the 0th capture group will always return the same
span as the span returned by <code>get_match</code>. This is because the 0th
capture group always corresponds to the entirety of the pattern’s
match. (It is similarly always unnamed because it is implicit.) This
isn’t necessarily true of all regex engines. For example, one can
hand-compile a <ahref="../../nfa/thompson/struct.NFA.html"title="struct regex_automata::nfa::thompson::NFA"><code>thompson::NFA</code></a> via a
<ahref="../../nfa/thompson/struct.Builder.html"title="struct regex_automata::nfa::thompson::Builder"><code>thompson::Builder</code></a>, which isn’t
technically forced to make the 0th capturing group always correspond to
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.get_group_by_name"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#507-510">source</a><h4class="code-header">pub fn <ahref="#method.get_group_by_name"class="fn">get_group_by_name</a>(&self, name: &<aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.str.html">str</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../../struct.Span.html"title="struct regex_automata::Span">Span</a>></h4></section></summary><divclass="docblock"><p>Returns the span of a capturing group match corresponding to the group
name given, only if both the overall pattern matched and the capturing
group participated in that match.</p>
<p>This returns <code>None</code> if <code>name</code> does not correspond to a valid capturing
group for the pattern that matched.</p>
<p>This always returns <code>None</code> when <code>Captures</code> was created with
<ahref="struct.Captures.html#method.empty"title="associated function regex_automata::util::captures::Captures::empty"><code>Captures::empty</code></a>, even if a match was found. This also always
returns <code>None</code> for any <code>index > 0</code> when <code>Captures</code> was created with
<ahref="struct.Captures.html#method.matches"title="associated function regex_automata::util::captures::Captures::matches"><code>Captures::matches</code></a>.</p>
<p>If this routine returns a non-<code>None</code> value, then <code>is_match</code> is
guaranteed to return <code>true</code>, <code>pattern</code> is guaranteed to return a
non-<code>None</code> value and <code>get_match</code> is guaranteed to return a non-<code>None</code>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.iter"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#576-583">source</a><h4class="code-header">pub fn <ahref="#method.iter"class="fn">iter</a>(&self) -><aclass="struct"href="struct.CapturesPatternIter.html"title="struct regex_automata::util::captures::CapturesPatternIter">CapturesPatternIter</a><'_><ahref="#"class="tooltip"data-notable-ty="CapturesPatternIter<'_>">ⓘ</a></h4></section></summary><divclass="docblock"><p>Returns an iterator of possible spans for every capturing group in the
matching pattern.</p>
<p>If this <code>Captures</code> value does not correspond to a match, then the
iterator returned yields no elements.</p>
<p>Note that the iterator returned yields elements of type <code>Option<Span></code>.
A span is present if and only if it corresponds to a capturing group
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.group_len"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#615-621">source</a><h4class="code-header">pub fn <ahref="#method.group_len"class="fn">group_len</a>(&self) -><aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.usize.html">usize</a></h4></section></summary><divclass="docblock"><p>Return the total number of capturing groups for the matching pattern.</p>
<p>If this <code>Captures</code> value does not correspond to a match, then this
always returns <code>0</code>.</p>
<p>This always returns the same number of elements yielded by
<ahref="struct.Captures.html#method.iter"title="method regex_automata::util::captures::Captures::iter"><code>Captures::iter</code></a>. That is, the number includes capturing groups even
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.group_info"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#674-676">source</a><h4class="code-header">pub fn <ahref="#method.group_info"class="fn">group_info</a>(&self) ->&<aclass="struct"href="struct.GroupInfo.html"title="struct regex_automata::util::captures::GroupInfo">GroupInfo</a></h4></section></summary><divclass="docblock"><p>Returns a reference to the underlying group info on which these
captures are based.</p>
<p>The difference between <code>GroupInfo</code> and <code>Captures</code> is that the former
defines the structure of capturing groups where as the latter is what
stores the actual match information. So where as <code>Captures</code> only gives
you access to the current match, <code>GroupInfo</code> lets you query any
information about all capturing groups, even ones for patterns that
weren’t involved in a match.</p>
<p>Note that a <code>GroupInfo</code> uses reference counting internally, so it may
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.interpolate_string"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#716-724">source</a><h4class="code-header">pub fn <ahref="#method.interpolate_string"class="fn">interpolate_string</a>(&self, haystack: &<aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.str.html">str</a>, replacement: &<aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.str.html">str</a>) -><aclass="struct"href="https://doc.rust-lang.org/1.77.2/alloc/string/struct.String.html"title="struct alloc::string::String">String</a></h4></section></summary><divclass="docblock"><p>Interpolates the capture references in <code>replacement</code> with the
corresponding substrings in <code>haystack</code> matched by each reference. The
interpolated string is returned.</p>
<p>See the <ahref="../interpolate/index.html"title="mod regex_automata::util::interpolate"><code>interpolate</code> module</a> for documentation on the
)</h4></section></summary><divclass="docblock"><p>Interpolates the capture references in <code>replacement</code> with the
corresponding substrings in <code>haystack</code> matched by each reference. The
interpolated string is written to <code>dst</code>.</p>
<p>See the <ahref="../interpolate/index.html"title="mod regex_automata::util::interpolate"><code>interpolate</code> module</a> for documentation on the
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.interpolate_bytes"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#824-832">source</a><h4class="code-header">pub fn <ahref="#method.interpolate_bytes"class="fn">interpolate_bytes</a>(&self, haystack: &[<aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.u8.html">u8</a>], replacement: &[<aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.u8.html">u8</a>]) -><aclass="struct"href="https://doc.rust-lang.org/1.77.2/alloc/vec/struct.Vec.html"title="struct alloc::vec::Vec">Vec</a><<aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.u8.html">u8</a>></h4></section></summary><divclass="docblock"><p>Interpolates the capture references in <code>replacement</code> with the
corresponding substrings in <code>haystack</code> matched by each reference. The
interpolated byte string is returned.</p>
<p>See the <ahref="../interpolate/index.html"title="mod regex_automata::util::interpolate"><code>interpolate</code> module</a> for documentation on the
)</h4></section></summary><divclass="docblock"><p>Interpolates the capture references in <code>replacement</code> with the
corresponding substrings in <code>haystack</code> matched by each reference. The
interpolated byte string is written to <code>dst</code>.</p>
<p>See the <ahref="../interpolate/index.html"title="mod regex_automata::util::interpolate"><code>interpolate</code> module</a> for documentation on the
) -> (&'h <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.str.html">str</a>, [&'h <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.str.html">str</a>; <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.array.html">N</a>])</h4></section></summary><divclass="docblock"><p>This is a convenience routine for extracting the substrings
corresponding to matching capture groups in the given <code>haystack</code>. The
<code>haystack</code> should be the same substring used to find the match spans in
this <code>Captures</code> value.</p>
<p>This is identical to <ahref="struct.Captures.html#method.extract_bytes"title="method regex_automata::util::captures::Captures::extract_bytes"><code>Captures::extract_bytes</code></a>, except it works with
<code>&str</code> instead of <code>&[u8]</code>.</p>
) -> (&'h [<aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.u8.html">u8</a>], [&'h [<aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.u8.html">u8</a>]; <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.array.html">N</a>])</h4></section></summary><divclass="docblock"><p>This is a convenience routine for extracting the substrings
corresponding to matching capture groups in the given <code>haystack</code>. The
<code>haystack</code> should be the same substring used to find the match spans in
this <code>Captures</code> value.</p>
<p>This is identical to <ahref="struct.Captures.html#method.extract"title="method regex_automata::util::captures::Captures::extract"><code>Captures::extract</code></a>, except it works with
<code>&[u8]</code> instead of <code>&str</code>.</p>
</div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Captures-1"class="impl"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#1010-1202">source</a><ahref="#impl-Captures-1"class="anchor">§</a><h3class="code-header">impl <aclass="struct"href="struct.Captures.html"title="struct regex_automata::util::captures::Captures">Captures</a></h3></section></summary><divclass="docblock"><p>Lower level “slot” oriented APIs. One does not typically need to use these
when executing a search. They are instead mostly intended for folks that
are writing their own regex engine while reusing this <code>Captures</code> type.</p>
</div><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.clear"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#1071-1076">source</a><h4class="code-header">pub fn <ahref="#method.clear"class="fn">clear</a>(&mut self)</h4></section></summary><divclass="docblock"><p>Clear this <code>Captures</code> value.</p>
<p>After clearing, all slots inside this <code>Captures</code> value will be set to
<code>None</code>. Similarly, any pattern ID that it was previously associated
with (for a match) is erased.</p>
<p>It is not usually necessary to call this routine. Namely, a <code>Captures</code>
value only provides high level access to the capturing groups of the
pattern that matched, and only low level access to individual slots.
Thus, even if slots corresponding to groups that aren’t associated
with the matching pattern are set, then it won’t impact the higher
level APIs. Namely, higher level APIs like <ahref="struct.Captures.html#method.get_group"title="method regex_automata::util::captures::Captures::get_group"><code>Captures::get_group</code></a> will
return <code>None</code> if no pattern ID is present, even if there are spans set
in the underlying slots.</p>
<p>Thus, to “clear” a <code>Captures</code> value of a match, it is usually only
necessary to call <ahref="struct.Captures.html#method.set_pattern"title="method regex_automata::util::captures::Captures::set_pattern"><code>Captures::set_pattern</code></a> with <code>None</code>.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.slots"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#1187-1189">source</a><h4class="code-header">pub fn <ahref="#method.slots"class="fn">slots</a>(&self) ->&[<aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../primitives/struct.NonMaxUsize.html"title="struct regex_automata::util::primitives::NonMaxUsize">NonMaxUsize</a>>]</h4></section></summary><divclass="docblock"><p>Returns the underlying slots, where each slot stores a single offset.</p>
<p>Every matching capturing group generally corresponds to two slots: one
slot for the starting position and another for the ending position.
Typically, either both are present or neither are. (The weasel word
“typically” is used here because it really depends on the regex engine
implementation. Every sensible regex engine likely adheres to this
invariant, and every regex engine in this crate is sensible.)</p>
<p>Generally speaking, callers should prefer to use higher level routines
like <ahref="struct.Captures.html#method.get_match"title="method regex_automata::util::captures::Captures::get_match"><code>Captures::get_match</code></a> or <ahref="struct.Captures.html#method.get_group"title="method regex_automata::util::captures::Captures::get_group"><code>Captures::get_group</code></a>.</p>
<p>An important note here is that a regex engine may not reset all of the
slots to <code>None</code> values when no match occurs, or even when a match of
a different pattern occurs. But this depends on how the regex engine
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.slots_mut"class="method"><aclass="src rightside"href="../../../src/regex_automata/util/captures.rs.html#1199-1201">source</a><h4class="code-header">pub fn <ahref="#method.slots_mut"class="fn">slots_mut</a>(&mut self) ->&mut [<aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="../primitives/struct.NonMaxUsize.html"title="struct regex_automata::util::primitives::NonMaxUsize">NonMaxUsize</a>>]</h4></section></summary><divclass="docblock"><p>Returns the underlying slots as a mutable slice, where each slot stores
<p>This tends to be most useful for regex engine implementations for
writing offsets for matching capturing groups to slots.</p>
<p>See <ahref="struct.Captures.html#method.slots"title="method regex_automata::util::captures::Captures::slots"><code>Captures::slots</code></a> for more information about slots.</p>
<code><ahref="https://doc.rust-lang.org/1.77.2/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.77.2/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.77.2/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.77.2/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.77.2/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.77.2/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.77.2/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.77.2/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.77.2/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.77.2/alloc/borrow/trait.ToOwned.html#method.clone_into"class="fn">clone_into</a>(&self, target: <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/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.77.2/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.77.2/src/core/convert/mod.rs.html#804-806">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.77.2/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.77.2/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-1"class="associatedtype trait-impl"><ahref="#associatedtype.Error-1"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html#associatedtype.Error"class="associatedtype">Error</a> = <aclass="enum"href="https://doc.rust-lang.org/1.77.2/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.77.2/src/core/convert/mod.rs.html#811">source</a><ahref="#method.try_from"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html#tymethod.try_from"class="fn">try_from</a>(value: U) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/result/enum.Result.html"title="enum core::result::Result">Result</a><T, <T as <aclass="trait"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><U>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.77.2/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.77.2/src/core/convert/mod.rs.html#789-791">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.77.2/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.77.2/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"class="associatedtype trait-impl"><ahref="#associatedtype.Error"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryInto.html#associatedtype.Error"class="associatedtype">Error</a> = <U as <aclass="trait"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.77.2/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.77.2/src/core/convert/mod.rs.html#796">source</a><ahref="#method.try_into"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryInto.html#tymethod.try_into"class="fn">try_into</a>(self) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/result/enum.Result.html"title="enum core::result::Result">Result</a><U, <U as <aclass="trait"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.77.2/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">{"CapturesPatternIter<'_>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.CapturesPatternIter.html\" title=\"struct regex_automata::util::captures::CapturesPatternIter\">CapturesPatternIter</a><'a></code></h3><pre><code><div class=\"where\">impl<'a> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.77.2/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"struct.CapturesPatternIter.html\" title=\"struct regex_automata::util::captures::CapturesPatternIter\">CapturesPatternIter</a><'a></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.77.2/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = <a class=\"enum\" href=\"https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html\" title=\"enum core::option::Option\">Option</a><<a class=\"struct\" href=\"../../struct.Span.html\" title=\"struct regex_automata::Span\">Span</a>>;</div>"}</script></section></div></main></body></html>