mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-27 19:32:14 +00:00
296 lines
79 KiB
HTML
296 lines
79 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 `Regex` struct in crate `regex`."><meta name="keywords" content="rust, rustlang, rust-lang, Regex"><title>regex::bytes::Regex - 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='../../regex/index.html'><div class='logo-container'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Struct Regex</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.as_str">as_str</a><a href="#method.capture_locations">capture_locations</a><a href="#method.capture_names">capture_names</a><a href="#method.captures">captures</a><a href="#method.captures_iter">captures_iter</a><a href="#method.captures_len">captures_len</a><a href="#method.captures_read">captures_read</a><a href="#method.captures_read_at">captures_read_at</a><a href="#method.find">find</a><a href="#method.find_at">find_at</a><a href="#method.find_iter">find_iter</a><a href="#method.is_match">is_match</a><a href="#method.is_match_at">is_match_at</a><a href="#method.new">new</a><a href="#method.replace">replace</a><a href="#method.replace_all">replace_all</a><a href="#method.replacen">replacen</a><a href="#method.shortest_match">shortest_match</a><a href="#method.shortest_match_at">shortest_match_at</a><a href="#method.split">split</a><a href="#method.splitn">splitn</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-Display">Display</a><a href="#impl-FromStr">FromStr</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-ToString">ToString</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'>regex</a>::<wbr><a href='index.html'>bytes</a></p><script>window.sidebarCurrent = {name: 'Regex', 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/regex/re_bytes.rs.html#64' title='goto source code'>[src]</a></span><span class='in-band'>Struct <a href='../index.html'>regex</a>::<wbr><a href='index.html'>bytes</a>::<wbr><a class="struct" href=''>Regex</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust struct'>pub struct Regex(_);</pre></div><div class='docblock'><p>A compiled regular expression for matching arbitrary bytes.</p>
|
||
<p>It can be used to search, split or replace text. All searching is done with
|
||
an implicit <code>.*?</code> at the beginning and end of an expression. To force an
|
||
expression to match the whole string (or a prefix or a suffix), you must
|
||
use an anchor like <code>^</code> or <code>$</code> (or <code>\A</code> and <code>\z</code>).</p>
|
||
<p>Like the <code>Regex</code> type in the parent module, matches with this regex return
|
||
byte offsets into the search text. <strong>Unlike</strong> the parent <code>Regex</code> type,
|
||
these byte offsets may not correspond to UTF-8 sequence boundaries since
|
||
the regexes in this module can match arbitrary bytes.</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="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</a></code><a href='#impl' class='anchor'></a><a class='srclink' href='../../src/regex/re_bytes.rs.html#100-516' title='goto source code'>[src]</a></h3><div class='docblock'><p>Core regular expression methods.</p>
|
||
</div><div class='impl-items'><h4 id='method.new' class="method"><code id='new.v'>pub fn <a href='#method.new' class='fnname'>new</a>(re: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> <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="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</a>, <a class="enum" href="../../regex/enum.Error.html" title="enum regex::Error">Error</a>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#105-107' title='goto source code'>[src]</a></h4><div class='docblock'><p>Compiles a regular expression. Once compiled, it can be used repeatedly
|
||
to search, split or replace text in a string.</p>
|
||
<p>If an invalid expression is given, then an error is returned.</p>
|
||
</div><h4 id='method.is_match' class="method"><code id='is_match.v'>pub fn <a href='#method.is_match' class='fnname'>is_match</a>(&self, text: <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>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#127-129' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns true if and only if the regex matches the string given.</p>
|
||
<p>It is recommended to use this method if all you need to do is test
|
||
a match, since the underlying matching engine may be able to do less
|
||
work.</p>
|
||
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
|
||
<p>Test if some text contains at least one word with exactly 13 ASCII word
|
||
bytes:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">text</span> <span class="op">=</span> <span class="string">b"I categorically deny having triskaidekaphobia."</span>;
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"\b\w{13}\b"</span>).<span class="ident">unwrap</span>().<span class="ident">is_match</span>(<span class="ident">text</span>));</pre></div>
|
||
</div><h4 id='method.find' class="method"><code id='find.v'>pub fn <a href='#method.find' class='fnname'>find</a><'t>(&self, text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="../../regex/bytes/struct.Match.html" title="struct regex::bytes::Match">Match</a><'t>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#151-153' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the start and end byte range of the leftmost-first match in
|
||
<code>text</code>. If no match exists, then <code>None</code> is returned.</p>
|
||
<p>Note that this should only be used if you want to discover the position
|
||
of the match. Testing the existence of a match is faster if you use
|
||
<code>is_match</code>.</p>
|
||
<h1 id="example-1" class="section-header"><a href="#example-1">Example</a></h1>
|
||
<p>Find the start and end location of the first word with exactly 13
|
||
ASCII word bytes:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">text</span> <span class="op">=</span> <span class="string">b"I categorically deny having triskaidekaphobia."</span>;
|
||
<span class="kw">let</span> <span class="ident">mat</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"\b\w{13}\b"</span>).<span class="ident">unwrap</span>().<span class="ident">find</span>(<span class="ident">text</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="ident">mat</span>.<span class="ident">start</span>(), <span class="ident">mat</span>.<span class="ident">end</span>()), (<span class="number">2</span>, <span class="number">15</span>));</pre></div>
|
||
</div><h4 id='method.find_iter' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../regex/bytes/struct.Matches.html" title="struct regex::bytes::Matches">Matches</a><'r, 't></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../regex/bytes/struct.Matches.html" title="struct regex::bytes::Matches">Matches</a><'r, 't></h3><code class="content"><span class="where fmt-newline">impl<'r, 't> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../../regex/bytes/struct.Matches.html" title="struct regex::bytes::Matches">Matches</a><'r, 't></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="struct" href="../../regex/bytes/struct.Match.html" title="struct regex::bytes::Match">Match</a><'t>;</span></code></div></div><code id='find_iter.v'>pub fn <a href='#method.find_iter' class='fnname'>find_iter</a><'r, 't>(&'r self, text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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>) -> <a class="struct" href="../../regex/bytes/struct.Matches.html" title="struct regex::bytes::Matches">Matches</a><'r, 't></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#173-175' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator for each successive non-overlapping match in
|
||
<code>text</code>, returning the start and end byte indices with respect to
|
||
<code>text</code>.</p>
|
||
<h1 id="example-2" class="section-header"><a href="#example-2">Example</a></h1>
|
||
<p>Find the start and end location of every word with exactly 13 ASCII
|
||
word bytes:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">text</span> <span class="op">=</span> <span class="string">b"Retroactively relinquishing remunerations is reprehensible."</span>;
|
||
<span class="kw">for</span> <span class="ident">mat</span> <span class="kw">in</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"\b\w{13}\b"</span>).<span class="ident">unwrap</span>().<span class="ident">find_iter</span>(<span class="ident">text</span>) {
|
||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"{:?}"</span>, <span class="ident">mat</span>);
|
||
}</pre></div>
|
||
</div><h4 id='method.captures' class="method"><code id='captures.v'>pub fn <a href='#method.captures' class='fnname'>captures</a><'t>(&self, text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="../../regex/bytes/struct.Captures.html" title="struct regex::bytes::Captures">Captures</a><'t>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#240-247' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the capture groups corresponding to the leftmost-first
|
||
match in <code>text</code>. Capture group <code>0</code> always corresponds to the entire
|
||
match. If no match is found, then <code>None</code> is returned.</p>
|
||
<p>You should only use <code>captures</code> if you need access to the location of
|
||
capturing group matches. Otherwise, <code>find</code> is faster for discovering
|
||
the location of the overall match.</p>
|
||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||
<p>Say you have some text with movie names and their release years,
|
||
like "'Citizen Kane' (1941)". It'd be nice if we could search for text
|
||
looking like that, while also extracting the movie name and its release
|
||
year separately.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"'([^']+)'\s+\((\d{4})\)"</span>).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="ident">text</span> <span class="op">=</span> <span class="string">b"Not my favorite movie: 'Citizen Kane' (1941)."</span>;
|
||
<span class="kw">let</span> <span class="ident">caps</span> <span class="op">=</span> <span class="ident">re</span>.<span class="ident">captures</span>(<span class="ident">text</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">caps</span>.<span class="ident">get</span>(<span class="number">1</span>).<span class="ident">unwrap</span>().<span class="ident">as_bytes</span>(), <span class="kw-2">&</span><span class="string">b"Citizen Kane"</span>[..]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">caps</span>.<span class="ident">get</span>(<span class="number">2</span>).<span class="ident">unwrap</span>().<span class="ident">as_bytes</span>(), <span class="kw-2">&</span><span class="string">b"1941"</span>[..]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">caps</span>.<span class="ident">get</span>(<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">as_bytes</span>(), <span class="kw-2">&</span><span class="string">b"'Citizen Kane' (1941)"</span>[..]);
|
||
<span class="comment">// You can also access the groups by index using the Index notation.</span>
|
||
<span class="comment">// Note that this will panic on an invalid index.</span>
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">caps</span>[<span class="number">1</span>], <span class="string">b"Citizen Kane"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">caps</span>[<span class="number">2</span>], <span class="string">b"1941"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">caps</span>[<span class="number">0</span>], <span class="string">b"'Citizen Kane' (1941)"</span>);</pre></div>
|
||
<p>Note that the full match is at capture group <code>0</code>. Each subsequent
|
||
capture group is indexed by the order of its opening <code>(</code>.</p>
|
||
<p>We can make this example a bit clearer by using <em>named</em> capture groups:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)"</span>)
|
||
.<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="ident">text</span> <span class="op">=</span> <span class="string">b"Not my favorite movie: 'Citizen Kane' (1941)."</span>;
|
||
<span class="kw">let</span> <span class="ident">caps</span> <span class="op">=</span> <span class="ident">re</span>.<span class="ident">captures</span>(<span class="ident">text</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">caps</span>.<span class="ident">name</span>(<span class="string">"title"</span>).<span class="ident">unwrap</span>().<span class="ident">as_bytes</span>(), <span class="string">b"Citizen Kane"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">caps</span>.<span class="ident">name</span>(<span class="string">"year"</span>).<span class="ident">unwrap</span>().<span class="ident">as_bytes</span>(), <span class="string">b"1941"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">caps</span>.<span class="ident">get</span>(<span class="number">0</span>).<span class="ident">unwrap</span>().<span class="ident">as_bytes</span>(), <span class="kw-2">&</span><span class="string">b"'Citizen Kane' (1941)"</span>[..]);
|
||
<span class="comment">// You can also access the groups by name using the Index notation.</span>
|
||
<span class="comment">// Note that this will panic on an invalid group name.</span>
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">caps</span>[<span class="string">"title"</span>], <span class="string">b"Citizen Kane"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">caps</span>[<span class="string">"year"</span>], <span class="string">b"1941"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">caps</span>[<span class="number">0</span>], <span class="string">b"'Citizen Kane' (1941)"</span>);
|
||
</pre></div>
|
||
<p>Here we name the capture groups, which we can access with the <code>name</code>
|
||
method or the <code>Index</code> notation with a <code>&str</code>. Note that the named
|
||
capture groups are still accessible with <code>get</code> or the <code>Index</code> notation
|
||
with a <code>usize</code>.</p>
|
||
<p>The <code>0</code>th capture group is always unnamed, so it must always be
|
||
accessed with <code>get(0)</code> or <code>[0]</code>.</p>
|
||
</div><h4 id='method.captures_iter' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../regex/bytes/struct.CaptureMatches.html" title="struct regex::bytes::CaptureMatches">CaptureMatches</a><'r, 't></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../regex/bytes/struct.CaptureMatches.html" title="struct regex::bytes::CaptureMatches">CaptureMatches</a><'r, 't></h3><code class="content"><span class="where fmt-newline">impl<'r, 't> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../../regex/bytes/struct.CaptureMatches.html" title="struct regex::bytes::CaptureMatches">CaptureMatches</a><'r, 't></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="struct" href="../../regex/bytes/struct.Captures.html" title="struct regex::bytes::Captures">Captures</a><'t>;</span></code></div></div><code id='captures_iter.v'>pub fn <a href='#method.captures_iter' class='fnname'>captures_iter</a><'r, 't>(&'r self, text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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>) -> <a class="struct" href="../../regex/bytes/struct.CaptureMatches.html" title="struct regex::bytes::CaptureMatches">CaptureMatches</a><'r, 't></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#275-280' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over all the non-overlapping capture groups matched
|
||
in <code>text</code>. This is operationally the same as <code>find_iter</code>, except it
|
||
yields information about capturing group matches.</p>
|
||
<h1 id="example-3" class="section-header"><a href="#example-3">Example</a></h1>
|
||
<p>We can use this to find all movie titles and their release years in
|
||
some text, where the movie is formatted like "'Title' (xxxx)":</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)"</span>)
|
||
.<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="ident">text</span> <span class="op">=</span> <span class="string">b"'Citizen Kane' (1941), 'The Wizard of Oz' (1939), 'M' (1931)."</span>;
|
||
<span class="kw">for</span> <span class="ident">caps</span> <span class="kw">in</span> <span class="ident">re</span>.<span class="ident">captures_iter</span>(<span class="ident">text</span>) {
|
||
<span class="kw">let</span> <span class="ident">title</span> <span class="op">=</span> <span class="ident">str</span>::<span class="ident">from_utf8</span>(<span class="kw-2">&</span><span class="ident">caps</span>[<span class="string">"title"</span>]).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="ident">year</span> <span class="op">=</span> <span class="ident">str</span>::<span class="ident">from_utf8</span>(<span class="kw-2">&</span><span class="ident">caps</span>[<span class="string">"year"</span>]).<span class="ident">unwrap</span>();
|
||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Movie: {:?}, Released: {:?}"</span>, <span class="ident">title</span>, <span class="ident">year</span>);
|
||
}
|
||
<span class="comment">// Output:</span>
|
||
<span class="comment">// Movie: Citizen Kane, Released: 1941</span>
|
||
<span class="comment">// Movie: The Wizard of Oz, Released: 1939</span>
|
||
<span class="comment">// Movie: M, Released: 1931</span></pre></div>
|
||
</div><h4 id='method.split' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../regex/bytes/struct.Split.html" title="struct regex::bytes::Split">Split</a><'r, 't></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../regex/bytes/struct.Split.html" title="struct regex::bytes::Split">Split</a><'r, 't></h3><code class="content"><span class="where fmt-newline">impl<'r, 't> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../../regex/bytes/struct.Split.html" title="struct regex::bytes::Split">Split</a><'r, 't></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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></div></div><code id='split.v'>pub fn <a href='#method.split' class='fnname'>split</a><'r, 't>(&'r self, text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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>) -> <a class="struct" href="../../regex/bytes/struct.Split.html" title="struct regex::bytes::Split">Split</a><'r, 't></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#302-304' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator of substrings of <code>text</code> delimited by a match of the
|
||
regular expression. Namely, each element of the iterator corresponds to
|
||
text that <em>isn't</em> matched by the regular expression.</p>
|
||
<p>This method will <em>not</em> copy the text given.</p>
|
||
<h1 id="example-4" class="section-header"><a href="#example-4">Example</a></h1>
|
||
<p>To split a string delimited by arbitrary amounts of spaces or tabs:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"[ \t]+"</span>).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="ident">fields</span>: <span class="ident">Vec</span><span class="op"><</span><span class="kw-2">&</span>[<span class="ident">u8</span>]<span class="op">></span> <span class="op">=</span> <span class="ident">re</span>.<span class="ident">split</span>(<span class="string">b"a b \t c\td e"</span>).<span class="ident">collect</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">fields</span>, <span class="macro">vec</span><span class="macro">!</span>[
|
||
<span class="kw-2">&</span><span class="string">b"a"</span>[..], <span class="kw-2">&</span><span class="string">b"b"</span>[..], <span class="kw-2">&</span><span class="string">b"c"</span>[..], <span class="kw-2">&</span><span class="string">b"d"</span>[..], <span class="kw-2">&</span><span class="string">b"e"</span>[..],
|
||
]);</pre></div>
|
||
</div><h4 id='method.splitn' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../regex/bytes/struct.SplitN.html" title="struct regex::bytes::SplitN">SplitN</a><'r, 't></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../regex/bytes/struct.SplitN.html" title="struct regex::bytes::SplitN">SplitN</a><'r, 't></h3><code class="content"><span class="where fmt-newline">impl<'r, 't> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../../regex/bytes/struct.SplitN.html" title="struct regex::bytes::SplitN">SplitN</a><'r, 't></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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></div></div><code id='splitn.v'>pub fn <a href='#method.splitn' class='fnname'>splitn</a><'r, 't>(&'r self, text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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>, limit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="struct" href="../../regex/bytes/struct.SplitN.html" title="struct regex::bytes::SplitN">SplitN</a><'r, 't></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#326-332' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator of at most <code>limit</code> substrings of <code>text</code> delimited
|
||
by a match of the regular expression. (A <code>limit</code> of <code>0</code> will return no
|
||
substrings.) Namely, each element of the iterator corresponds to text
|
||
that <em>isn't</em> matched by the regular expression. The remainder of the
|
||
string that is not split will be the last element in the iterator.</p>
|
||
<p>This method will <em>not</em> copy the text given.</p>
|
||
<h1 id="example-5" class="section-header"><a href="#example-5">Example</a></h1>
|
||
<p>Get the first two words in some text:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"\W+"</span>).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="ident">fields</span>: <span class="ident">Vec</span><span class="op"><</span><span class="kw-2">&</span>[<span class="ident">u8</span>]<span class="op">></span> <span class="op">=</span> <span class="ident">re</span>.<span class="ident">splitn</span>(<span class="string">b"Hey! How are you?"</span>, <span class="number">3</span>).<span class="ident">collect</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">fields</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="kw-2">&</span><span class="string">b"Hey"</span>[..], <span class="kw-2">&</span><span class="string">b"How"</span>[..], <span class="kw-2">&</span><span class="string">b"are you?"</span>[..]]);</pre></div>
|
||
</div><h4 id='method.replace' class="method"><code id='replace.v'>pub fn <a href='#method.replace' class='fnname'>replace</a><'t, R: <a class="trait" href="../../regex/bytes/trait.Replacer.html" title="trait regex::bytes::Replacer">Replacer</a>>(&self, text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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>, rep: R) -> <a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'t, <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>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#442-448' title='goto source code'>[src]</a></h4><div class='docblock'><p>Replaces the leftmost-first match with the replacement provided. The
|
||
replacement can be a regular byte string (where <code>$N</code> and <code>$name</code> are
|
||
expanded to match capture groups) or a function that takes the matches'
|
||
<code>Captures</code> and returns the replaced byte string.</p>
|
||
<p>If no match is found, then a copy of the byte string is returned
|
||
unchanged.</p>
|
||
<h1 id="replacement-string-syntax" class="section-header"><a href="#replacement-string-syntax">Replacement string syntax</a></h1>
|
||
<p>All instances of <code>$name</code> in the replacement text is replaced with the
|
||
corresponding capture group <code>name</code>.</p>
|
||
<p><code>name</code> may be an integer corresponding to the index of the
|
||
capture group (counted by order of opening parenthesis where <code>0</code> is the
|
||
entire match) or it can be a name (consisting of letters, digits or
|
||
underscores) corresponding to a named capture group.</p>
|
||
<p>If <code>name</code> isn't a valid capture group (whether the name doesn't exist
|
||
or isn't a valid index), then it is replaced with the empty string.</p>
|
||
<p>The longest possible name is used. e.g., <code>$1a</code> looks up the capture
|
||
group named <code>1a</code> and not the capture group at index <code>1</code>. To exert more
|
||
precise control over the name, use braces, e.g., <code>${1}a</code>.</p>
|
||
<p>To write a literal <code>$</code> use <code>$$</code>.</p>
|
||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||
<p>Note that this function is polymorphic with respect to the replacement.
|
||
In typical usage, this can just be a normal byte string:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">"[^01]+"</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">re</span>.<span class="ident">replace</span>(<span class="string">b"1078910"</span>, <span class="kw-2">&</span><span class="string">b""</span>[..]), <span class="kw-2">&</span><span class="string">b"1010"</span>[..]);</pre></div>
|
||
<p>But anything satisfying the <code>Replacer</code> trait will work. For example, a
|
||
closure of type <code>|&Captures| -> Vec<u8></code> provides direct access to the
|
||
captures corresponding to a match. This allows one to access capturing
|
||
group matches easily:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"([^,\s]+),\s+(\S+)"</span>).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">re</span>.<span class="ident">replace</span>(<span class="string">b"Springsteen, Bruce"</span>, <span class="op">|</span><span class="ident">caps</span>: <span class="kw-2">&</span><span class="ident">Captures</span><span class="op">|</span> {
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">replacement</span> <span class="op">=</span> <span class="ident">caps</span>[<span class="number">2</span>].<span class="ident">to_owned</span>();
|
||
<span class="ident">replacement</span>.<span class="ident">push</span>(<span class="string">b' '</span>);
|
||
<span class="ident">replacement</span>.<span class="ident">extend</span>(<span class="kw-2">&</span><span class="ident">caps</span>[<span class="number">1</span>]);
|
||
<span class="ident">replacement</span>
|
||
});
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">result</span>, <span class="kw-2">&</span><span class="string">b"Bruce Springsteen"</span>[..]);</pre></div>
|
||
<p>But this is a bit cumbersome to use all the time. Instead, a simple
|
||
syntax is supported that expands <code>$name</code> into the corresponding capture
|
||
group. Here's the last example, but using this expansion technique
|
||
with named capture groups:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"(?P<last>[^,\s]+),\s+(?P<first>\S+)"</span>).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">re</span>.<span class="ident">replace</span>(<span class="string">b"Springsteen, Bruce"</span>, <span class="kw-2">&</span><span class="string">b"$first $last"</span>[..]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">result</span>, <span class="kw-2">&</span><span class="string">b"Bruce Springsteen"</span>[..]);</pre></div>
|
||
<p>Note that using <code>$2</code> instead of <code>$first</code> or <code>$1</code> instead of <code>$last</code>
|
||
would produce the same result. To write a literal <code>$</code> use <code>$$</code>.</p>
|
||
<p>Sometimes the replacement string requires use of curly braces to
|
||
delineate a capture group replacement and surrounding literal text.
|
||
For example, if we wanted to join two words together with an
|
||
underscore:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"(?P<first>\w+)\s+(?P<second>\w+)"</span>).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">re</span>.<span class="ident">replace</span>(<span class="string">b"deep fried"</span>, <span class="kw-2">&</span><span class="string">b"${first}_$second"</span>[..]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">result</span>, <span class="kw-2">&</span><span class="string">b"deep_fried"</span>[..]);</pre></div>
|
||
<p>Without the curly braces, the capture group name <code>first_</code> would be
|
||
used, and since it doesn't exist, it would be replaced with the empty
|
||
string.</p>
|
||
<p>Finally, sometimes you just want to replace a literal string with no
|
||
regard for capturing group expansion. This can be done by wrapping a
|
||
byte string with <code>NoExpand</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">regex</span>::<span class="ident">bytes</span>::<span class="ident">NoExpand</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">re</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"(?P<last>[^,\s]+),\s+(\S+)"</span>).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">re</span>.<span class="ident">replace</span>(<span class="string">b"Springsteen, Bruce"</span>, <span class="ident">NoExpand</span>(<span class="string">b"$2 $last"</span>));
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">result</span>, <span class="kw-2">&</span><span class="string">b"$2 $last"</span>[..]);</pre></div>
|
||
</div><h4 id='method.replace_all' class="method"><code id='replace_all.v'>pub fn <a href='#method.replace_all' class='fnname'>replace_all</a><'t, R: <a class="trait" href="../../regex/bytes/trait.Replacer.html" title="trait regex::bytes::Replacer">Replacer</a>>(<br> &self, <br> text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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> rep: R<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'t, <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>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#456-462' title='goto source code'>[src]</a></h4><div class='docblock'><p>Replaces all non-overlapping matches in <code>text</code> with the replacement
|
||
provided. This is the same as calling <code>replacen</code> with <code>limit</code> set to
|
||
<code>0</code>.</p>
|
||
<p>See the documentation for <code>replace</code> for details on how to access
|
||
capturing group matches in the replacement text.</p>
|
||
</div><h4 id='method.replacen' class="method"><code id='replacen.v'>pub fn <a href='#method.replacen' class='fnname'>replacen</a><'t, R: <a class="trait" href="../../regex/bytes/trait.Replacer.html" title="trait regex::bytes::Replacer">Replacer</a>>(<br> &self, <br> text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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> limit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <br> rep: R<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'t, <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>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#470-515' title='goto source code'>[src]</a></h4><div class='docblock'><p>Replaces at most <code>limit</code> non-overlapping matches in <code>text</code> with the
|
||
replacement provided. If <code>limit</code> is 0, then all non-overlapping matches
|
||
are replaced.</p>
|
||
<p>See the documentation for <code>replace</code> for details on how to access
|
||
capturing group matches in the replacement text.</p>
|
||
</div></div><h3 id='impl-1' class='impl'><code class='in-band'>impl <a class="struct" href="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</a></code><a href='#impl-1' class='anchor'></a><a class='srclink' href='../../src/regex/re_bytes.rs.html#519-636' title='goto source code'>[src]</a></h3><div class='docblock'><p>Advanced or "lower level" search methods.</p>
|
||
</div><div class='impl-items'><h4 id='method.shortest_match' class="method"><code id='shortest_match.v'>pub fn <a href='#method.shortest_match' class='fnname'>shortest_match</a>(&self, text: <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>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#541-543' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the end location of a match in the text given.</p>
|
||
<p>This method may have the same performance characteristics as
|
||
<code>is_match</code>, except it provides an end location for a match. In
|
||
particular, the location returned <em>may be shorter</em> than the proper end
|
||
of the leftmost-first match.</p>
|
||
<h1 id="example-6" class="section-header"><a href="#example-6">Example</a></h1>
|
||
<p>Typically, <code>a+</code> would match the entire first sequence of <code>a</code> in some
|
||
text, but <code>shortest_match</code> can give up as soon as it sees the first
|
||
<code>a</code>.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">text</span> <span class="op">=</span> <span class="string">b"aaaaa"</span>;
|
||
<span class="kw">let</span> <span class="ident">pos</span> <span class="op">=</span> <span class="ident">Regex</span>::<span class="ident">new</span>(<span class="string">r"a+"</span>).<span class="ident">unwrap</span>().<span class="ident">shortest_match</span>(<span class="ident">text</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">pos</span>, <span class="prelude-val">Some</span>(<span class="number">1</span>));</pre></div>
|
||
</div><h4 id='method.shortest_match_at' class="method"><code id='shortest_match_at.v'>pub fn <a href='#method.shortest_match_at' class='fnname'>shortest_match_at</a>(&self, text: <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>, start: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#551-557' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the same as shortest_match, but starts the search at the given
|
||
offset.</p>
|
||
<p>The significance of the starting point is that it takes the surrounding
|
||
context into consideration. For example, the <code>\A</code> anchor can only
|
||
match when <code>start == 0</code>.</p>
|
||
</div><h4 id='method.is_match_at' class="method"><code id='is_match_at.v'>pub fn <a href='#method.is_match_at' class='fnname'>is_match_at</a>(&self, text: <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>, start: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#565-567' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the same as is_match, but starts the search at the given
|
||
offset.</p>
|
||
<p>The significance of the starting point is that it takes the surrounding
|
||
context into consideration. For example, the <code>\A</code> anchor can only
|
||
match when <code>start == 0</code>.</p>
|
||
</div><h4 id='method.find_at' class="method"><code id='find_at.v'>pub fn <a href='#method.find_at' class='fnname'>find_at</a><'t>(&self, text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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>, start: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="../../regex/bytes/struct.Match.html" title="struct regex::bytes::Match">Match</a><'t>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#575-584' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the same as find, but starts the search at the given
|
||
offset.</p>
|
||
<p>The significance of the starting point is that it takes the surrounding
|
||
context into consideration. For example, the <code>\A</code> anchor can only
|
||
match when <code>start == 0</code>.</p>
|
||
</div><h4 id='method.captures_read' class="method"><code id='captures_read.v'>pub fn <a href='#method.captures_read' class='fnname'>captures_read</a><'t>(<br> &self, <br> locs: &mut <a class="struct" href="../../regex/bytes/struct.CaptureLocations.html" title="struct regex::bytes::CaptureLocations">CaptureLocations</a>, <br> text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="../../regex/bytes/struct.Match.html" title="struct regex::bytes::Match">Match</a><'t>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#596-602' title='goto source code'>[src]</a></h4><div class='docblock'><p>This is like <code>captures</code>, but uses
|
||
<a href="struct.CaptureLocations.html"><code>CaptureLocations</code></a>
|
||
instead of
|
||
<a href="struct.Captures.html"><code>Captures</code></a> in order to amortize allocations.</p>
|
||
<p>To create a <code>CaptureLocations</code> value, use the
|
||
<code>Regex::capture_locations</code> method.</p>
|
||
<p>This returns the overall match if this was successful, which is always
|
||
equivalence to the <code>0</code>th capture group.</p>
|
||
</div><h4 id='method.captures_read_at' class="method"><code id='captures_read_at.v'>pub fn <a href='#method.captures_read_at' class='fnname'>captures_read_at</a><'t>(<br> &self, <br> locs: &mut <a class="struct" href="../../regex/bytes/struct.CaptureLocations.html" title="struct regex::bytes::CaptureLocations">CaptureLocations</a>, <br> text: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&'t [</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> start: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="../../regex/bytes/struct.Match.html" title="struct regex::bytes::Match">Match</a><'t>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#610-620' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the same as <code>captures_read</code>, but starts the search at the given
|
||
offset and populates the capture locations given.</p>
|
||
<p>The significance of the starting point is that it takes the surrounding
|
||
context into consideration. For example, the <code>\A</code> anchor can only
|
||
match when <code>start == 0</code>.</p>
|
||
</div></div><h3 id='impl-2' class='impl'><code class='in-band'>impl <a class="struct" href="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</a></code><a href='#impl-2' class='anchor'></a><a class='srclink' href='../../src/regex/re_bytes.rs.html#639-669' title='goto source code'>[src]</a></h3><div class='docblock'><p>Auxiliary methods.</p>
|
||
</div><div class='impl-items'><h4 id='method.as_str' class="method"><code id='as_str.v'>pub fn <a href='#method.as_str' class='fnname'>as_str</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#641-643' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the original string of this regex.</p>
|
||
</div><h4 id='method.capture_names' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../../regex/bytes/struct.CaptureNames.html" title="struct regex::bytes::CaptureNames">CaptureNames</a><'r></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../../regex/bytes/struct.CaptureNames.html" title="struct regex::bytes::CaptureNames">CaptureNames</a><'r></h3><code class="content"><span class="where fmt-newline">impl<'r> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../../regex/bytes/struct.CaptureNames.html" title="struct regex::bytes::CaptureNames">CaptureNames</a><'r></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&'r <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>;</span></code></div></div><code id='capture_names.v'>pub fn <a href='#method.capture_names' class='fnname'>capture_names</a>(&self) -> <a class="struct" href="../../regex/bytes/struct.CaptureNames.html" title="struct regex::bytes::CaptureNames">CaptureNames</a></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#646-648' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an iterator over the capture names.</p>
|
||
</div><h4 id='method.captures_len' class="method"><code id='captures_len.v'>pub fn <a href='#method.captures_len' class='fnname'>captures_len</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#651-653' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the number of captures.</p>
|
||
</div><h4 id='method.capture_locations' class="method"><code id='capture_locations.v'>pub fn <a href='#method.capture_locations' class='fnname'>capture_locations</a>(&self) -> <a class="struct" href="../../regex/bytes/struct.CaptureLocations.html" title="struct regex::bytes::CaptureLocations">CaptureLocations</a></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#657-659' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns an empty set of capture locations that can be reused in
|
||
multiple calls to <code>captures_read</code> or <code>captures_read_at</code>.</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-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="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</a></code><a href='#impl-Clone' class='anchor'></a><a class='srclink' href='../../src/regex/re_bytes.rs.html#63' 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="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</a></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#63' 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-Display' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</a></code><a href='#impl-Display' class='anchor'></a><a class='srclink' href='../../src/regex/re_bytes.rs.html#66-71' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fmt' class="method"><code id='fmt.v'>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Display.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/regex/re_bytes.rs.html#68-70' title='goto source code'>[src]</a></h4><div class='docblock'><p>Shows the original regular expression.</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="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</a></code><a href='#impl-Debug' class='anchor'></a><a class='srclink' href='../../src/regex/re_bytes.rs.html#73-78' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fmt-1' class="method"><code id='fmt.v-1'>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/regex/re_bytes.rs.html#75-77' title='goto source code'>[src]</a></h4><div class='docblock'><p>Shows the original regular expression.</p>
|
||
</div></div><h3 id='impl-FromStr' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html" title="trait core::str::FromStr">FromStr</a> for <a class="struct" href="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</a></code><a href='#impl-FromStr' class='anchor'></a><a class='srclink' href='../../src/regex/re_bytes.rs.html#90-97' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Err' class="type"><code id='Err.t'>type <a href='https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html#associatedtype.Err' class="type">Err</a> = <a class="enum" href="../../regex/enum.Error.html" title="enum regex::Error">Error</a></code></h4><div class='docblock'><p>The associated error which can be returned from parsing.</p>
|
||
</div><h4 id='method.from_str' class="method"><code id='from_str.v'>fn <a href='https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html#tymethod.from_str' class='fnname'>from_str</a>(s: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> <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="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</a>, <a class="enum" href="../../regex/enum.Error.html" title="enum regex::Error">Error</a>></code><a class='srclink' href='../../src/regex/re_bytes.rs.html#94-96' title='goto source code'>[src]</a></h4><div class='docblock'><p>Attempts to parse a string into a regular expression</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="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</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="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</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="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</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="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</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="../../regex/bytes/struct.Regex.html" title="struct regex::bytes::Regex">Regex</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-ToString' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html" title="trait alloc::string::ToString">ToString</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + ?<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-ToString' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2134-2144' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.to_string' class="method hidden"><code id='to_string.v'>default fn <a href='https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string' class='fnname'>to_string</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2136-2143' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Converts the given value to a <code>String</code>. <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string">Read more</a></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 = "regex";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html> |