mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-15 04:28:25 +00:00
427 lines
60 KiB
HTML
427 lines
60 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="A configurable builder for a `Regex`."><title>RegexBuilder in regex::bytes - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-ac92e1bbe349e143.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="regex" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0 (07dca489a 2024-02-04)" data-channel="1.76.0" data-search-js="search-2b6ce74ff89ae146.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-f2adc0d6ca4d09fb.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-305769736d49e732.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-feafe1bb7466e4bd.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../regex/index.html">regex</a><span class="version">1.10.3</span></h2></div><h2 class="location"><a href="#">RegexBuilder</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.build">build</a></li><li><a href="#method.case_insensitive">case_insensitive</a></li><li><a href="#method.crlf">crlf</a></li><li><a href="#method.dfa_size_limit">dfa_size_limit</a></li><li><a href="#method.dot_matches_new_line">dot_matches_new_line</a></li><li><a href="#method.ignore_whitespace">ignore_whitespace</a></li><li><a href="#method.line_terminator">line_terminator</a></li><li><a href="#method.multi_line">multi_line</a></li><li><a href="#method.nest_limit">nest_limit</a></li><li><a href="#method.new">new</a></li><li><a href="#method.octal">octal</a></li><li><a href="#method.size_limit">size_limit</a></li><li><a href="#method.swap_greed">swap_greed</a></li><li><a href="#method.unicode">unicode</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Clone-for-RegexBuilder">Clone</a></li><li><a href="#impl-Debug-for-RegexBuilder">Debug</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-RefUnwindSafe-for-RegexBuilder">RefUnwindSafe</a></li><li><a href="#impl-Send-for-RegexBuilder">Send</a></li><li><a href="#impl-Sync-for-RegexBuilder">Sync</a></li><li><a href="#impl-Unpin-for-RegexBuilder">Unpin</a></li><li><a href="#impl-UnwindSafe-for-RegexBuilder">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation">
|
|||
|
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../../regex/all.html" title="show sidebar"></a></div><input class="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"><div id="help-button" tabindex="-1"><a href="../../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Struct <a href="../index.html">regex</a>::<wbr><a href="index.html">bytes</a>::<wbr><a class="struct" href="#">RegexBuilder</a><button id="copy-path" title="Copy item path to clipboard"><img src="../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../../src/regex/builders.rs.html#1372-1374">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><pre class="rust item-decl"><code>pub struct RegexBuilder { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A configurable builder for a <a href="struct.Regex.html" title="struct regex::bytes::Regex"><code>Regex</code></a>.</p>
|
|||
|
<p>This builder can be used to programmatically set flags such as <code>i</code>
|
|||
|
(case insensitive) and <code>x</code> (for verbose mode). This builder can also be
|
|||
|
used to configure things like the line terminator and a size limit on
|
|||
|
the compiled regular expression.</p>
|
|||
|
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-RegexBuilder" class="impl"><a class="src rightside" href="../../src/regex/builders.rs.html#1376-1957">source</a><a href="#impl-RegexBuilder" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1383-1385">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>(pattern: &<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.str.html">str</a>) -> <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>Create a new builder with a default configuration for the given
|
|||
|
pattern.</p>
|
|||
|
<p>If the pattern is invalid or exceeds the configured size limits,
|
|||
|
then an error will be returned when <a href="struct.RegexBuilder.html#method.build" title="method regex::bytes::RegexBuilder::build"><code>RegexBuilder::build</code></a> is
|
|||
|
called.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.build" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1392-1394">source</a><h4 class="code-header">pub fn <a href="#method.build" class="fn">build</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.Regex.html" title="struct regex::bytes::Regex">Regex</a>, <a class="enum" href="../enum.Error.html" title="enum regex::Error">Error</a>></h4></section></summary><div class="docblock"><p>Compiles the pattern given to <code>RegexBuilder::new</code> with the
|
|||
|
configuration set on this builder.</p>
|
|||
|
<p>If the pattern isn’t a valid regex or if a configured size limit
|
|||
|
was exceeded, then an error is returned.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.unicode" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1463-1466">source</a><h4 class="code-header">pub fn <a href="#method.unicode" class="fn">unicode</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>This configures Unicode mode for the entire pattern.</p>
|
|||
|
<p>Enabling Unicode mode does a number of things:</p>
|
|||
|
<ul>
|
|||
|
<li>Most fundamentally, it causes the fundamental atom of matching
|
|||
|
to be a single codepoint. When Unicode mode is disabled, it’s a
|
|||
|
single byte. For example, when Unicode mode is enabled, <code>.</code> will
|
|||
|
match <code>💩</code> once, where as it will match 4 times when Unicode mode
|
|||
|
is disabled. (Since the UTF-8 encoding of <code>💩</code> is 4 bytes long.)</li>
|
|||
|
<li>Case insensitive matching uses Unicode simple case folding rules.</li>
|
|||
|
<li>Unicode character classes like <code>\p{Letter}</code> and <code>\p{Greek}</code> are
|
|||
|
available.</li>
|
|||
|
<li>Perl character classes are Unicode aware. That is, <code>\w</code>, <code>\s</code> and
|
|||
|
<code>\d</code>.</li>
|
|||
|
<li>The word boundary assertions, <code>\b</code> and <code>\B</code>, use the Unicode
|
|||
|
definition of a word character.</li>
|
|||
|
</ul>
|
|||
|
<p>Note that unlike the top-level <code>Regex</code> for searching <code>&str</code>, it
|
|||
|
is permitted to disable Unicode mode even if the resulting pattern
|
|||
|
could match invalid UTF-8. For example, <code>(?-u:.)</code> is not a valid
|
|||
|
pattern for a top-level <code>Regex</code>, but is valid for a <code>bytes::Regex</code>.</p>
|
|||
|
<p>For more details on the Unicode support in this crate, see the
|
|||
|
<a href="../index.html#unicode" title="mod regex">Unicode section</a> in this crate’s top-level
|
|||
|
documentation.</p>
|
|||
|
<p>The default for this is <code>true</code>.</p>
|
|||
|
<h5 id="example"><a href="#example">Example</a></h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"\w"</span>)
|
|||
|
.unicode(<span class="bool-val">false</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="comment">// Normally greek letters would be included in \w, but since
|
|||
|
// Unicode mode is disabled, it only matches ASCII letters.
|
|||
|
</span><span class="macro">assert!</span>(!re.is_match(<span class="string">"δ"</span>.as_bytes()));
|
|||
|
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"s"</span>)
|
|||
|
.case_insensitive(<span class="bool-val">true</span>)
|
|||
|
.unicode(<span class="bool-val">false</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="comment">// Normally 'ſ' is included when searching for 's' case
|
|||
|
// insensitively due to Unicode's simple case folding rules. But
|
|||
|
// when Unicode mode is disabled, only ASCII case insensitive rules
|
|||
|
// are used.
|
|||
|
</span><span class="macro">assert!</span>(!re.is_match(<span class="string">"ſ"</span>.as_bytes()));</code></pre></div>
|
|||
|
<p>Since this builder is for constructing a <a href="struct.Regex.html" title="struct regex::bytes::Regex"><code>bytes::Regex</code></a>,
|
|||
|
one can disable Unicode mode even if it would match invalid UTF-8:</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"."</span>)
|
|||
|
.unicode(<span class="bool-val">false</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="comment">// Normally greek letters would be included in \w, but since
|
|||
|
// Unicode mode is disabled, it only matches ASCII letters.
|
|||
|
</span><span class="macro">assert!</span>(re.is_match(<span class="string">b"\xFF"</span>));</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.case_insensitive" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1492-1495">source</a><h4 class="code-header">pub fn <a href="#method.case_insensitive" class="fn">case_insensitive</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>This configures whether to enable case insensitive matching for the
|
|||
|
entire pattern.</p>
|
|||
|
<p>This setting can also be configured using the inline flag <code>i</code>
|
|||
|
in the pattern. For example, <code>(?i:foo)</code> matches <code>foo</code> case
|
|||
|
insensitively while <code>(?-i:foo)</code> matches <code>foo</code> case sensitively.</p>
|
|||
|
<p>The default for this is <code>false</code>.</p>
|
|||
|
<h5 id="example-1"><a href="#example-1">Example</a></h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"foo(?-i:bar)quux"</span>)
|
|||
|
.case_insensitive(<span class="bool-val">true</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="macro">assert!</span>(re.is_match(<span class="string">b"FoObarQuUx"</span>));
|
|||
|
<span class="comment">// Even though case insensitive matching is enabled in the builder,
|
|||
|
// it can be locally disabled within the pattern. In this case,
|
|||
|
// `bar` is matched case sensitively.
|
|||
|
</span><span class="macro">assert!</span>(!re.is_match(<span class="string">b"fooBARquux"</span>));</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.multi_line" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1531-1534">source</a><h4 class="code-header">pub fn <a href="#method.multi_line" class="fn">multi_line</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>This configures multi-line mode for the entire pattern.</p>
|
|||
|
<p>Enabling multi-line mode changes the behavior of the <code>^</code> and <code>$</code>
|
|||
|
anchor assertions. Instead of only matching at the beginning and
|
|||
|
end of a haystack, respectively, multi-line mode causes them to
|
|||
|
match at the beginning and end of a line <em>in addition</em> to the
|
|||
|
beginning and end of a haystack. More precisely, <code>^</code> will match at
|
|||
|
the position immediately following a <code>\n</code> and <code>$</code> will match at the
|
|||
|
position immediately preceding a <code>\n</code>.</p>
|
|||
|
<p>The behavior of this option can be impacted by other settings too:</p>
|
|||
|
<ul>
|
|||
|
<li>The <a href="struct.RegexBuilder.html#method.line_terminator" title="method regex::bytes::RegexBuilder::line_terminator"><code>RegexBuilder::line_terminator</code></a> option changes <code>\n</code> above
|
|||
|
to any ASCII byte.</li>
|
|||
|
<li>The <a href="struct.RegexBuilder.html#method.crlf" title="method regex::bytes::RegexBuilder::crlf"><code>RegexBuilder::crlf</code></a> option changes the line terminator to
|
|||
|
be either <code>\r</code> or <code>\n</code>, but never at the position between a <code>\r</code>
|
|||
|
and <code>\n</code>.</li>
|
|||
|
</ul>
|
|||
|
<p>This setting can also be configured using the inline flag <code>m</code> in
|
|||
|
the pattern.</p>
|
|||
|
<p>The default for this is <code>false</code>.</p>
|
|||
|
<h5 id="example-2"><a href="#example-2">Example</a></h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"^foo$"</span>)
|
|||
|
.multi_line(<span class="bool-val">true</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">1</span>..<span class="number">4</span>), re.find(<span class="string">b"\nfoo\n"</span>).map(|m| m.range()));</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.dot_matches_new_line" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1562-1568">source</a><h4 class="code-header">pub fn <a href="#method.dot_matches_new_line" class="fn">dot_matches_new_line</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>This configures dot-matches-new-line mode for the entire pattern.</p>
|
|||
|
<p>Perhaps surprisingly, the default behavior for <code>.</code> is not to match
|
|||
|
any character, but rather, to match any character except for the
|
|||
|
line terminator (which is <code>\n</code> by default). When this mode is
|
|||
|
enabled, the behavior changes such that <code>.</code> truly matches any
|
|||
|
character.</p>
|
|||
|
<p>This setting can also be configured using the inline flag <code>s</code> in
|
|||
|
the pattern. For example, <code>(?s:.)</code> and <code>\p{any}</code> are equivalent
|
|||
|
regexes.</p>
|
|||
|
<p>The default for this is <code>false</code>.</p>
|
|||
|
<h5 id="example-3"><a href="#example-3">Example</a></h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"foo.bar"</span>)
|
|||
|
.dot_matches_new_line(<span class="bool-val">true</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="kw">let </span>hay = <span class="string">b"foo\nbar"</span>;
|
|||
|
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b"foo\nbar"</span>[..]), re.find(hay).map(|m| m.as_bytes()));</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.crlf" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1620-1623">source</a><h4 class="code-header">pub fn <a href="#method.crlf" class="fn">crlf</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>This configures CRLF mode for the entire pattern.</p>
|
|||
|
<p>When CRLF mode is enabled, both <code>\r</code> (“carriage return” or CR for
|
|||
|
short) and <code>\n</code> (“line feed” or LF for short) are treated as line
|
|||
|
terminators. This results in the following:</p>
|
|||
|
<ul>
|
|||
|
<li>Unless dot-matches-new-line mode is enabled, <code>.</code> will now match
|
|||
|
any character except for <code>\n</code> and <code>\r</code>.</li>
|
|||
|
<li>When multi-line mode is enabled, <code>^</code> will match immediately
|
|||
|
following a <code>\n</code> or a <code>\r</code>. Similarly, <code>$</code> will match immediately
|
|||
|
preceding a <code>\n</code> or a <code>\r</code>. Neither <code>^</code> nor <code>$</code> will ever match
|
|||
|
between <code>\r</code> and <code>\n</code>.</li>
|
|||
|
</ul>
|
|||
|
<p>This setting can also be configured using the inline flag <code>R</code> in
|
|||
|
the pattern.</p>
|
|||
|
<p>The default for this is <code>false</code>.</p>
|
|||
|
<h5 id="example-4"><a href="#example-4">Example</a></h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"^foo$"</span>)
|
|||
|
.multi_line(<span class="bool-val">true</span>)
|
|||
|
.crlf(<span class="bool-val">true</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="kw">let </span>hay = <span class="string">b"\r\nfoo\r\n"</span>;
|
|||
|
<span class="comment">// If CRLF mode weren't enabled here, then '$' wouldn't match
|
|||
|
// immediately after 'foo', and thus no match would be found.
|
|||
|
</span><span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b"foo"</span>[..]), re.find(hay).map(|m| m.as_bytes()));</code></pre></div>
|
|||
|
<p>This example demonstrates that <code>^</code> will never match at a position
|
|||
|
between <code>\r</code> and <code>\n</code>. (<code>$</code> will similarly not match between a <code>\r</code>
|
|||
|
and a <code>\n</code>.)</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"^"</span>)
|
|||
|
.multi_line(<span class="bool-val">true</span>)
|
|||
|
.crlf(<span class="bool-val">true</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="kw">let </span>hay = <span class="string">b"\r\n\r\n"</span>;
|
|||
|
<span class="kw">let </span>ranges: Vec<<span class="kw">_</span>> = re.find_iter(hay).map(|m| m.range()).collect();
|
|||
|
<span class="macro">assert_eq!</span>(ranges, <span class="macro">vec!</span>[<span class="number">0</span>..<span class="number">0</span>, <span class="number">2</span>..<span class="number">2</span>, <span class="number">4</span>..<span class="number">4</span>]);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.line_terminator" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1694-1697">source</a><h4 class="code-header">pub fn <a href="#method.line_terminator" class="fn">line_terminator</a>(&mut self, byte: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>Configures the line terminator to be used by the regex.</p>
|
|||
|
<p>The line terminator is relevant in two ways for a particular regex:</p>
|
|||
|
<ul>
|
|||
|
<li>When dot-matches-new-line mode is <em>not</em> enabled (the default),
|
|||
|
then <code>.</code> will match any character except for the configured line
|
|||
|
terminator.</li>
|
|||
|
<li>When multi-line mode is enabled (not the default), then <code>^</code> and
|
|||
|
<code>$</code> will match immediately after and before, respectively, a line
|
|||
|
terminator.</li>
|
|||
|
</ul>
|
|||
|
<p>In both cases, if CRLF mode is enabled in a particular context,
|
|||
|
then it takes precedence over any configured line terminator.</p>
|
|||
|
<p>This option cannot be configured from within the pattern.</p>
|
|||
|
<p>The default line terminator is <code>\n</code>.</p>
|
|||
|
<h5 id="example-5"><a href="#example-5">Example</a></h5>
|
|||
|
<p>This shows how to treat the NUL byte as a line terminator. This can
|
|||
|
be a useful heuristic when searching binary data.</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"^foo$"</span>)
|
|||
|
.multi_line(<span class="bool-val">true</span>)
|
|||
|
.line_terminator(<span class="string">b'\x00'</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="kw">let </span>hay = <span class="string">b"\x00foo\x00"</span>;
|
|||
|
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">1</span>..<span class="number">4</span>), re.find(hay).map(|m| m.range()));</code></pre></div>
|
|||
|
<p>This example shows that the behavior of <code>.</code> is impacted by this
|
|||
|
setting as well:</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"."</span>)
|
|||
|
.line_terminator(<span class="string">b'\x00'</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="macro">assert!</span>(re.is_match(<span class="string">b"\n"</span>));
|
|||
|
<span class="macro">assert!</span>(!re.is_match(<span class="string">b"\x00"</span>));</code></pre></div>
|
|||
|
<p>This shows that building a regex will work even when the byte
|
|||
|
given is not ASCII. This is unlike the top-level <code>Regex</code> API where
|
|||
|
matching invalid UTF-8 is not allowed.</p>
|
|||
|
<p>Note though that you must disable Unicode mode. This is required
|
|||
|
because Unicode mode requires matching one codepoint at a time,
|
|||
|
and there is no way to match a non-ASCII byte as if it were a
|
|||
|
codepoint.</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="macro">assert!</span>(
|
|||
|
RegexBuilder::new(<span class="string">r"."</span>)
|
|||
|
.unicode(<span class="bool-val">false</span>)
|
|||
|
.line_terminator(<span class="number">0x80</span>)
|
|||
|
.build()
|
|||
|
.is_ok(),
|
|||
|
);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.swap_greed" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1721-1724">source</a><h4 class="code-header">pub fn <a href="#method.swap_greed" class="fn">swap_greed</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>This configures swap-greed mode for the entire pattern.</p>
|
|||
|
<p>When swap-greed mode is enabled, patterns like <code>a+</code> will become
|
|||
|
non-greedy and patterns like <code>a+?</code> will become greedy. In other
|
|||
|
words, the meanings of <code>a+</code> and <code>a+?</code> are switched.</p>
|
|||
|
<p>This setting can also be configured using the inline flag <code>U</code> in
|
|||
|
the pattern.</p>
|
|||
|
<p>The default for this is <code>false</code>.</p>
|
|||
|
<h5 id="example-6"><a href="#example-6">Example</a></h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"a+"</span>)
|
|||
|
.swap_greed(<span class="bool-val">true</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b"a"</span>[..]), re.find(<span class="string">b"aaa"</span>).map(|m| m.as_bytes()));</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.ignore_whitespace" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1795-1798">source</a><h4 class="code-header">pub fn <a href="#method.ignore_whitespace" class="fn">ignore_whitespace</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>This configures verbose mode for the entire pattern.</p>
|
|||
|
<p>When enabled, whitespace will treated as insignifcant in the
|
|||
|
pattern and <code>#</code> can be used to start a comment until the next new
|
|||
|
line.</p>
|
|||
|
<p>Normally, in most places in a pattern, whitespace is treated
|
|||
|
literally. For example <code> +</code> will match one or more ASCII whitespace
|
|||
|
characters.</p>
|
|||
|
<p>When verbose mode is enabled, <code>\#</code> can be used to match a literal
|
|||
|
<code>#</code> and <code>\ </code> can be used to match a literal ASCII whitespace
|
|||
|
character.</p>
|
|||
|
<p>Verbose mode is useful for permitting regexes to be formatted and
|
|||
|
broken up more nicely. This may make them more easily readable.</p>
|
|||
|
<p>This setting can also be configured using the inline flag <code>x</code> in
|
|||
|
the pattern.</p>
|
|||
|
<p>The default for this is <code>false</code>.</p>
|
|||
|
<h5 id="example-7"><a href="#example-7">Example</a></h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="kw">let </span>pat = <span class="string">r"
|
|||
|
\b
|
|||
|
(?<first>\p{Uppercase}\w*) # always start with uppercase letter
|
|||
|
[\s--\n]+ # whitespace should separate names
|
|||
|
(?: # middle name can be an initial!
|
|||
|
(?:(?<initial>\p{Uppercase})\.|(?<middle>\p{Uppercase}\w*))
|
|||
|
[\s--\n]+
|
|||
|
)?
|
|||
|
(?<last>\p{Uppercase}\w*)
|
|||
|
\b
|
|||
|
"</span>;
|
|||
|
<span class="kw">let </span>re = RegexBuilder::new(pat)
|
|||
|
.ignore_whitespace(<span class="bool-val">true</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
|
|||
|
<span class="kw">let </span>caps = re.captures(<span class="string">b"Harry Potter"</span>).unwrap();
|
|||
|
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span><span class="string">b"Harry"</span>[..], <span class="kw-2">&</span>caps[<span class="string">"first"</span>]);
|
|||
|
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span><span class="string">b"Potter"</span>[..], <span class="kw-2">&</span>caps[<span class="string">"last"</span>]);
|
|||
|
|
|||
|
<span class="kw">let </span>caps = re.captures(<span class="string">b"Harry J. Potter"</span>).unwrap();
|
|||
|
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span><span class="string">b"Harry"</span>[..], <span class="kw-2">&</span>caps[<span class="string">"first"</span>]);
|
|||
|
<span class="comment">// Since a middle name/initial isn't required for an overall match,
|
|||
|
// we can't assume that 'initial' or 'middle' will be populated!
|
|||
|
</span><span class="macro">assert_eq!</span>(
|
|||
|
<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b"J"</span>[..]),
|
|||
|
caps.name(<span class="string">"initial"</span>).map(|m| m.as_bytes()),
|
|||
|
);
|
|||
|
<span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, caps.name(<span class="string">"middle"</span>).map(|m| m.as_bytes()));
|
|||
|
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span><span class="string">b"Potter"</span>[..], <span class="kw-2">&</span>caps[<span class="string">"last"</span>]);
|
|||
|
|
|||
|
<span class="kw">let </span>caps = re.captures(<span class="string">b"Harry James Potter"</span>).unwrap();
|
|||
|
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span><span class="string">b"Harry"</span>[..], <span class="kw-2">&</span>caps[<span class="string">"first"</span>]);
|
|||
|
<span class="comment">// Since a middle name/initial isn't required for an overall match,
|
|||
|
// we can't assume that 'initial' or 'middle' will be populated!
|
|||
|
</span><span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, caps.name(<span class="string">"initial"</span>).map(|m| m.as_bytes()));
|
|||
|
<span class="macro">assert_eq!</span>(
|
|||
|
<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b"James"</span>[..]),
|
|||
|
caps.name(<span class="string">"middle"</span>).map(|m| m.as_bytes()),
|
|||
|
);
|
|||
|
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span><span class="string">b"Potter"</span>[..], <span class="kw-2">&</span>caps[<span class="string">"last"</span>]);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.octal" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1830-1833">source</a><h4 class="code-header">pub fn <a href="#method.octal" class="fn">octal</a>(&mut self, yes: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>This configures octal mode for the entire pattern.</p>
|
|||
|
<p>Octal syntax is a little-known way of uttering Unicode codepoints
|
|||
|
in a pattern. For example, <code>a</code>, <code>\x61</code>, <code>\u0061</code> and <code>\141</code> are all
|
|||
|
equivalent patterns, where the last example shows octal syntax.</p>
|
|||
|
<p>While supporting octal syntax isn’t in and of itself a problem,
|
|||
|
it does make good error messages harder. That is, in PCRE based
|
|||
|
regex engines, syntax like <code>\1</code> invokes a backreference, which is
|
|||
|
explicitly unsupported this library. However, many users expect
|
|||
|
backreferences to be supported. Therefore, when octal support
|
|||
|
is disabled, the error message will explicitly mention that
|
|||
|
backreferences aren’t supported.</p>
|
|||
|
<p>The default for this is <code>false</code>.</p>
|
|||
|
<h5 id="example-8"><a href="#example-8">Example</a></h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="comment">// Normally this pattern would not compile, with an error message
|
|||
|
// about backreferences not being supported. But with octal mode
|
|||
|
// enabled, octal escape sequences work.
|
|||
|
</span><span class="kw">let </span>re = RegexBuilder::new(<span class="string">r"\141"</span>)
|
|||
|
.octal(<span class="bool-val">true</span>)
|
|||
|
.build()
|
|||
|
.unwrap();
|
|||
|
<span class="macro">assert!</span>(re.is_match(<span class="string">b"a"</span>));</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.size_limit" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1869-1872">source</a><h4 class="code-header">pub fn <a href="#method.size_limit" class="fn">size_limit</a>(&mut self, bytes: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>Sets the approximate size limit, in bytes, of the compiled regex.</p>
|
|||
|
<p>This roughly corresponds to the number of heap memory, in
|
|||
|
bytes, occupied by a single regex. If the regex would otherwise
|
|||
|
approximately exceed this limit, then compiling that regex will
|
|||
|
fail.</p>
|
|||
|
<p>The main utility of a method like this is to avoid compiling
|
|||
|
regexes that use an unexpected amount of resources, such as
|
|||
|
time and memory. Even if the memory usage of a large regex is
|
|||
|
acceptable, its search time may not be. Namely, worst case time
|
|||
|
complexity for search is <code>O(m * n)</code>, where <code>m ~ len(pattern)</code> and
|
|||
|
<code>n ~ len(haystack)</code>. That is, search time depends, in part, on the
|
|||
|
size of the compiled regex. This means that putting a limit on the
|
|||
|
size of the regex limits how much a regex can impact search time.</p>
|
|||
|
<p>For more information about regex size limits, see the section on
|
|||
|
<a href="../index.html#untrusted-input" title="mod regex">untrusted inputs</a> in the top-level crate
|
|||
|
documentation.</p>
|
|||
|
<p>The default for this is some reasonable number that permits most
|
|||
|
patterns to compile successfully.</p>
|
|||
|
<h5 id="example-9"><a href="#example-9">Example</a></h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="comment">// It may surprise you how big some seemingly small patterns can
|
|||
|
// be! Since \w is Unicode aware, this generates a regex that can
|
|||
|
// match approximately 140,000 distinct codepoints.
|
|||
|
</span><span class="macro">assert!</span>(RegexBuilder::new(<span class="string">r"\w"</span>).size_limit(<span class="number">45_000</span>).build().is_err());</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.dfa_size_limit" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1912-1915">source</a><h4 class="code-header">pub fn <a href="#method.dfa_size_limit" class="fn">dfa_size_limit</a>(&mut self, bytes: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>Set the approximate capacity, in bytes, of the cache of transitions
|
|||
|
used by the lazy DFA.</p>
|
|||
|
<p>While the lazy DFA isn’t always used, in tends to be the most
|
|||
|
commonly use regex engine in default configurations. It tends to
|
|||
|
adopt the performance profile of a fully build DFA, but without the
|
|||
|
downside of taking worst case exponential time to build.</p>
|
|||
|
<p>The downside is that it needs to keep a cache of transitions and
|
|||
|
states that are built while running a search, and this cache
|
|||
|
can fill up. When it fills up, the cache will reset itself. Any
|
|||
|
previously generated states and transitions will then need to be
|
|||
|
re-generated. If this happens too many times, then this library
|
|||
|
will bail out of using the lazy DFA and switch to a different regex
|
|||
|
engine.</p>
|
|||
|
<p>If your regex provokes this particular downside of the lazy DFA,
|
|||
|
then it may be beneficial to increase its cache capacity. This will
|
|||
|
potentially reduce the frequency of cache resetting (ideally to
|
|||
|
<code>0</code>). While it won’t fix all potential performance problems with
|
|||
|
the lazy DFA, increasing the cache capacity does fix some.</p>
|
|||
|
<p>There is no easy way to determine, a priori, whether increasing
|
|||
|
this cache capacity will help. In general, the larger your regex,
|
|||
|
the more cache it’s likely to use. But that isn’t an ironclad rule.
|
|||
|
For example, a regex like <code>[01]*1[01]{N}</code> would normally produce a
|
|||
|
fully build DFA that is exponential in size with respect to <code>N</code>.
|
|||
|
The lazy DFA will prevent exponential space blow-up, but it cache
|
|||
|
is likely to fill up, even when it’s large and even for smallish
|
|||
|
values of <code>N</code>.</p>
|
|||
|
<p>If you aren’t sure whether this helps or not, it is sensible to
|
|||
|
set this to some arbitrarily large number in testing, such as
|
|||
|
<code>usize::MAX</code>. Namely, this represents the amount of capacity that
|
|||
|
<em>may</em> be used. It’s probably not a good idea to use <code>usize::MAX</code> in
|
|||
|
production though, since it implies there are no controls on heap
|
|||
|
memory used by this library during a search. In effect, set it to
|
|||
|
whatever you’re willing to allocate for a single regex search.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.nest_limit" class="method"><a class="src rightside" href="../../src/regex/builders.rs.html#1953-1956">source</a><h4 class="code-header">pub fn <a href="#method.nest_limit" class="fn">nest_limit</a>(&mut self, limit: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>) -> &mut <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class="docblock"><p>Set the nesting limit for this parser.</p>
|
|||
|
<p>The nesting limit controls how deep the abstract syntax tree is
|
|||
|
allowed to be. If the AST exceeds the given limit (e.g., with too
|
|||
|
many nested groups), then an error is returned by the parser.</p>
|
|||
|
<p>The purpose of this limit is to act as a heuristic to prevent stack
|
|||
|
overflow for consumers that do structural induction on an AST using
|
|||
|
explicit recursion. While this crate never does this (instead using
|
|||
|
constant stack space and moving the call stack to the heap), other
|
|||
|
crates may.</p>
|
|||
|
<p>This limit is not checked until the entire AST is parsed.
|
|||
|
Therefore, if callers want to put a limit on the amount of heap
|
|||
|
space used, then they should impose a limit on the length, in
|
|||
|
bytes, of the concrete pattern string. In particular, this is
|
|||
|
viable since this parser implementation will limit itself to heap
|
|||
|
space proportional to the length of the pattern string. See also
|
|||
|
the <a href="../index.html#untrusted-input" title="mod regex">untrusted inputs</a> section in the
|
|||
|
top-level crate documentation for more information about this.</p>
|
|||
|
<p>Note that a nest limit of <code>0</code> will return a nest limit error for
|
|||
|
most patterns but not all. For example, a nest limit of <code>0</code> permits
|
|||
|
<code>a</code> but not <code>ab</code>, since <code>ab</code> requires an explicit concatenation,
|
|||
|
which results in a nest depth of <code>1</code>. In general, a nest limit is
|
|||
|
not something that manifests in an obvious way in the concrete
|
|||
|
syntax, therefore, it should not be used in a granular way.</p>
|
|||
|
<h5 id="example-10"><a href="#example-10">Example</a></h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex::bytes::RegexBuilder;
|
|||
|
|
|||
|
<span class="macro">assert!</span>(RegexBuilder::new(<span class="string">r"a"</span>).nest_limit(<span class="number">0</span>).build().is_ok());
|
|||
|
<span class="macro">assert!</span>(RegexBuilder::new(<span class="string">r"ab"</span>).nest_limit(<span class="number">0</span>).build().is_err());</code></pre></div>
|
|||
|
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Clone-for-RegexBuilder" class="impl"><a class="src rightside" href="../../src/regex/builders.rs.html#1371">source</a><a href="#impl-Clone-for-RegexBuilder" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl"><a class="src rightside" href="../../src/regex/builders.rs.html#1371">source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&self) -> <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/clone.rs.html#169">source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&Self</a>)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-RegexBuilder" class="impl"><a class="src rightside" href="../../src/regex/builders.rs.html#1371">source</a><a href="#impl-Debug-for-RegexBuilder" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.RegexBuilder.html" title="struct regex::bytes::RegexBuilder">RegexBuilder</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../../src/regex/builders.rs.html#1371">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.76.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-RegexBuilder" class="impl"><a href="#impl-RefUnwindSafe-for-RegexBuilder" class="anchor">§</a><h3 clas
|
|||
|
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
|||
|
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
|||
|
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#763">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#766">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
|||
|
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#747-749">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#756">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
|||
|
<p>That is, this conversion is whatever the implementation of
|
|||
|
<code><a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
|||
|
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ToOwned-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#83-85">source</a><a href="#impl-ToOwned-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<div class="where">where
|
|||
|
T: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl"><a href="#associatedtype.Owned" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#88">source</a><a href="#method.to_owned" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fn">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#92">source</a><a href="#method.clone_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fn">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&mut T</a>)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#803-805">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#810">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#788-790">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#795">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>
|