mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-22 16:08:24 +00:00
258 lines
56 KiB
HTML
258 lines
56 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 high-level intermediate representation (HIR) for a regular expression."><title>Hir in regex_syntax::hir - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="regex_syntax" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0 (051478957 2024-07-21)" data-channel="1.80.0" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-df360f571f6edeae.css"></noscript><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" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../regex_syntax/index.html">regex_syntax</a><span class="version">0.8.4</span></h2></div><h2 class="location"><a href="#">Hir</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.alternation">alternation</a></li><li><a href="#method.capture">capture</a></li><li><a href="#method.class">class</a></li><li><a href="#method.concat">concat</a></li><li><a href="#method.dot">dot</a></li><li><a href="#method.empty">empty</a></li><li><a href="#method.fail">fail</a></li><li><a href="#method.into_kind">into_kind</a></li><li><a href="#method.kind">kind</a></li><li><a href="#method.literal">literal</a></li><li><a href="#method.look">look</a></li><li><a href="#method.properties">properties</a></li><li><a href="#method.repetition">repetition</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Clone-for-Hir">Clone</a></li><li><a href="#impl-Debug-for-Hir">Debug</a></li><li><a href="#impl-Display-for-Hir">Display</a></li><li><a href="#impl-Drop-for-Hir">Drop</a></li><li><a href="#impl-Eq-for-Hir">Eq</a></li><li><a href="#impl-PartialEq-for-Hir">PartialEq</a></li><li><a href="#impl-StructuralPartialEq-for-Hir">StructuralPartialEq</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Hir">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Hir">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Hir">Send</a></li><li><a href="#impl-Sync-for-Hir">Sync</a></li><li><a href="#impl-Unpin-for-Hir">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Hir">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T">Into<U></a></li><li><a href="#impl-ToOwned-for-T">ToOwned</a></li><li><a href="#impl-ToString-for-T">ToString</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T">TryInto<U></a></li></ul></section><h2><a href="index.html">In regex_syntax::hir</a></h2></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Struct <a href="../index.html">regex_syntax</a>::<wbr><a href="index.html">hir</a>::<wbr><a class="struct" href="#">Hir</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../../src/regex_syntax/hir/mod.rs.html#205-210">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><pre class="rust item-decl"><code>pub struct Hir { <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 high-level intermediate representation (HIR) for a regular expression.</p>
|
||
<p>An HIR value is a combination of a <a href="enum.HirKind.html" title="enum regex_syntax::hir::HirKind"><code>HirKind</code></a> and a set of <a href="struct.Properties.html" title="struct regex_syntax::hir::Properties"><code>Properties</code></a>.
|
||
An <code>HirKind</code> indicates what kind of regular expression it is (a literal,
|
||
a repetition, a look-around assertion, etc.), where as a <code>Properties</code>
|
||
describes various facts about the regular expression. For example, whether
|
||
it matches UTF-8 or if it matches the empty string.</p>
|
||
<p>The HIR of a regular expression represents an intermediate step between
|
||
its abstract syntax (a structured description of the concrete syntax) and
|
||
an actual regex matcher. The purpose of HIR is to make regular expressions
|
||
easier to analyze. In particular, the AST is much more complex than the
|
||
HIR. For example, while an AST supports arbitrarily nested character
|
||
classes, the HIR will flatten all nested classes into a single set. The HIR
|
||
will also “compile away” every flag present in the concrete syntax. For
|
||
example, users of HIR expressions never need to worry about case folding;
|
||
it is handled automatically by the translator (e.g., by translating
|
||
<code>(?i:A)</code> to <code>[aA]</code>).</p>
|
||
<p>The specific type of an HIR expression can be accessed via its <code>kind</code>
|
||
or <code>into_kind</code> methods. This extra level of indirection exists for two
|
||
reasons:</p>
|
||
<ol>
|
||
<li>Construction of an HIR expression <em>must</em> use the constructor methods on
|
||
this <code>Hir</code> type instead of building the <code>HirKind</code> values directly. This
|
||
permits construction to enforce invariants like “concatenations always
|
||
consist of two or more sub-expressions.”</li>
|
||
<li>Every HIR expression contains attributes that are defined inductively,
|
||
and can be computed cheaply during the construction process. For example,
|
||
one such attribute is whether the expression must match at the beginning of
|
||
the haystack.</li>
|
||
</ol>
|
||
<p>In particular, if you have an <code>HirKind</code> value, then there is intentionally
|
||
no way to build an <code>Hir</code> value from it. You instead need to do case
|
||
analysis on the <code>HirKind</code> value and build the <code>Hir</code> value using its smart
|
||
constructors.</p>
|
||
<h2 id="utf-8"><a class="doc-anchor" href="#utf-8">§</a>UTF-8</h2>
|
||
<p>If the HIR was produced by a translator with
|
||
<a href="translate/struct.TranslatorBuilder.html#method.utf8" title="method regex_syntax::hir::translate::TranslatorBuilder::utf8"><code>TranslatorBuilder::utf8</code></a> enabled,
|
||
then the HIR is guaranteed to match UTF-8 exclusively for all non-empty
|
||
matches.</p>
|
||
<p>For empty matches, those can occur at any position. It is the
|
||
responsibility of the regex engine to determine whether empty matches are
|
||
permitted between the code units of a single codepoint.</p>
|
||
<h2 id="stack-space"><a class="doc-anchor" href="#stack-space">§</a>Stack space</h2>
|
||
<p>This type defines its own destructor that uses constant stack space and
|
||
heap space proportional to the size of the HIR.</p>
|
||
<p>Also, an <code>Hir</code>’s <code>fmt::Display</code> implementation prints an HIR as a regular
|
||
expression pattern string, and uses constant stack space and heap space
|
||
proportional to the size of the <code>Hir</code>. The regex it prints is guaranteed to
|
||
be <em>semantically</em> equivalent to the original concrete syntax, but it may
|
||
look very different. (And potentially not practically readable by a human.)</p>
|
||
<p>An <code>Hir</code>’s <code>fmt::Debug</code> implementation currently does not use constant
|
||
stack space. The implementation will also suppress some details (such as
|
||
the <code>Properties</code> inlined into every <code>Hir</code> value to make it less noisy).</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-Hir" class="impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#213-240">source</a><a href="#impl-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section></summary><div class="docblock"><p>Methods for accessing the underlying <code>HirKind</code> and <code>Properties</code>.</p>
|
||
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.kind" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#215-217">source</a><h4 class="code-header">pub fn <a href="#method.kind" class="fn">kind</a>(&self) -> &<a class="enum" href="enum.HirKind.html" title="enum regex_syntax::hir::HirKind">HirKind</a></h4></section></summary><div class="docblock"><p>Returns a reference to the underlying HIR kind.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_kind" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#221-223">source</a><h4 class="code-header">pub fn <a href="#method.into_kind" class="fn">into_kind</a>(self) -> <a class="enum" href="enum.HirKind.html" title="enum regex_syntax::hir::HirKind">HirKind</a></h4></section></summary><div class="docblock"><p>Consumes ownership of this HIR expression and returns its underlying
|
||
<code>HirKind</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.properties" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#226-228">source</a><h4 class="code-header">pub fn <a href="#method.properties" class="fn">properties</a>(&self) -> &<a class="struct" href="struct.Properties.html" title="struct regex_syntax::hir::Properties">Properties</a></h4></section></summary><div class="docblock"><p>Returns the properties computed for this <code>Hir</code>.</p>
|
||
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Hir-1" class="impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#253-707">source</a><a href="#impl-Hir-1" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section></summary><div class="docblock"><p>Smart constructors for HIR values.</p>
|
||
<p>These constructors are called “smart” because they do inductive work or
|
||
simplifications. For example, calling <code>Hir::repetition</code> with a repetition
|
||
like <code>a{0}</code> will actually return a <code>Hir</code> with a <code>HirKind::Empty</code> kind
|
||
since it is equivalent to an empty regex. Another example is calling
|
||
<code>Hir::concat(vec![expr])</code>. Instead of getting a <code>HirKind::Concat</code>, you’ll
|
||
just get back the original <code>expr</code> since it’s precisely equivalent.</p>
|
||
<p>Smart constructors enable maintaining invariants about the HIR data type
|
||
while also simulanteously keeping the representation as simple as possible.</p>
|
||
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.empty" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#258-261">source</a><h4 class="code-header">pub fn <a href="#method.empty" class="fn">empty</a>() -> <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h4></section></summary><div class="docblock"><p>Returns an empty HIR expression.</p>
|
||
<p>An empty HIR expression always matches, including the empty string.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.fail" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#279-286">source</a><h4 class="code-header">pub fn <a href="#method.fail" class="fn">fail</a>() -> <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h4></section></summary><div class="docblock"><p>Returns an HIR expression that can never match anything. That is,
|
||
the size of the set of strings in the language described by the HIR
|
||
returned is <code>0</code>.</p>
|
||
<p>This is distinct from <a href="struct.Hir.html#method.empty" title="associated function regex_syntax::hir::Hir::empty"><code>Hir::empty</code></a> in that the empty string matches
|
||
the HIR returned by <code>Hir::empty</code>. That is, the set of strings in the
|
||
language describe described by <code>Hir::empty</code> is non-empty.</p>
|
||
<p>Note that currently, the HIR returned uses an empty character class to
|
||
indicate that nothing can match. An equivalent expression that cannot
|
||
match is an empty alternation, but all such “fail” expressions are
|
||
normalized (via smart constructors) to empty character classes. This is
|
||
because empty character classes can be spelled in the concrete syntax
|
||
of a regex (e.g., <code>\P{any}</code> or <code>(?-u:[^\x00-\xFF])</code> or <code>[a&&b]</code>), but
|
||
empty alternations cannot.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.literal" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#342-351">source</a><h4 class="code-header">pub fn <a href="#method.literal" class="fn">literal</a><B: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><[<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.u8.html">u8</a>]>>>(lit: B) -> <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h4></section></summary><div class="docblock"><p>Creates a literal HIR expression.</p>
|
||
<p>This accepts anything that can be converted into a <code>Box<[u8]></code>.</p>
|
||
<p>Note that there is no mechanism for storing a <code>char</code> or a <code>Box<str></code>
|
||
in an HIR. Everything is “just bytes.” Whether a <code>Literal</code> (or
|
||
any HIR node) matches valid UTF-8 exclusively can be queried via
|
||
<a href="struct.Properties.html#method.is_utf8" title="method regex_syntax::hir::Properties::is_utf8"><code>Properties::is_utf8</code></a>.</p>
|
||
<h5 id="example"><a class="doc-anchor" href="#example">§</a>Example</h5>
|
||
<p>This example shows that concatenations of <code>Literal</code> HIR values will
|
||
automatically get flattened and combined together. So for example, even
|
||
if you concat multiple <code>Literal</code> values that are themselves not valid
|
||
UTF-8, they might add up to valid UTF-8. This also demonstrates just
|
||
how “smart” Hir’s smart constructors are.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::{Hir, HirKind, Literal};
|
||
|
||
<span class="kw">let </span>literals = <span class="macro">vec!</span>[
|
||
Hir::literal([<span class="number">0xE2</span>]),
|
||
Hir::literal([<span class="number">0x98</span>]),
|
||
Hir::literal([<span class="number">0x83</span>]),
|
||
];
|
||
<span class="comment">// Each literal, on its own, is invalid UTF-8.
|
||
</span><span class="macro">assert!</span>(literals.iter().all(|hir| !hir.properties().is_utf8()));
|
||
|
||
<span class="kw">let </span>concat = Hir::concat(literals);
|
||
<span class="comment">// But the concatenation is valid UTF-8!
|
||
</span><span class="macro">assert!</span>(concat.properties().is_utf8());
|
||
|
||
<span class="comment">// And also notice that the literals have been concatenated into a
|
||
// single `Literal`, to the point where there is no explicit `Concat`!
|
||
</span><span class="kw">let </span>expected = HirKind::Literal(Literal(Box::from(<span class="string">"☃"</span>.as_bytes())));
|
||
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span>expected, concat.kind());</code></pre></div>
|
||
<h5 id="example-building-a-literal-from-a-char"><a class="doc-anchor" href="#example-building-a-literal-from-a-char">§</a>Example: building a literal from a <code>char</code></h5>
|
||
<p>This example shows how to build a single <code>Hir</code> literal from a <code>char</code>
|
||
value. Since a <a href="struct.Literal.html" title="struct regex_syntax::hir::Literal"><code>Literal</code></a> is just bytes, we just need to UTF-8
|
||
encode a <code>char</code> value:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::{Hir, HirKind, Literal};
|
||
|
||
<span class="kw">let </span>ch = <span class="string">'☃'</span>;
|
||
<span class="kw">let </span>got = Hir::literal(ch.encode_utf8(<span class="kw-2">&mut </span>[<span class="number">0</span>; <span class="number">4</span>]).as_bytes());
|
||
|
||
<span class="kw">let </span>expected = HirKind::Literal(Literal(Box::from(<span class="string">"☃"</span>.as_bytes())));
|
||
<span class="macro">assert_eq!</span>(<span class="kw-2">&</span>expected, got.kind());</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.class" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#359-367">source</a><h4 class="code-header">pub fn <a href="#method.class" class="fn">class</a>(class: <a class="enum" href="enum.Class.html" title="enum regex_syntax::hir::Class">Class</a>) -> <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h4></section></summary><div class="docblock"><p>Creates a class HIR expression. The class may either be defined over
|
||
ranges of Unicode codepoints or ranges of raw byte values.</p>
|
||
<p>Note that an empty class is permitted. An empty class is equivalent to
|
||
<code>Hir::fail()</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.look" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#371-374">source</a><h4 class="code-header">pub fn <a href="#method.look" class="fn">look</a>(look: <a class="enum" href="enum.Look.html" title="enum regex_syntax::hir::Look">Look</a>) -> <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h4></section></summary><div class="docblock"><p>Creates a look-around assertion HIR expression.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.repetition" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#378-397">source</a><h4 class="code-header">pub fn <a href="#method.repetition" class="fn">repetition</a>(rep: <a class="struct" href="struct.Repetition.html" title="struct regex_syntax::hir::Repetition">Repetition</a>) -> <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h4></section></summary><div class="docblock"><p>Creates a repetition HIR expression.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.capture" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#407-410">source</a><h4 class="code-header">pub fn <a href="#method.capture" class="fn">capture</a>(capture: <a class="struct" href="struct.Capture.html" title="struct regex_syntax::hir::Capture">Capture</a>) -> <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h4></section></summary><div class="docblock"><p>Creates a capture HIR expression.</p>
|
||
<p>Note that there is no explicit HIR value for a non-capturing group.
|
||
Since a non-capturing group only exists to override precedence in the
|
||
concrete syntax and since an HIR already does its own grouping based on
|
||
what is parsed, there is no need to explicitly represent non-capturing
|
||
groups in the HIR.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.concat" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#439-502">source</a><h4 class="code-header">pub fn <a href="#method.concat" class="fn">concat</a>(subs: <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a>>) -> <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h4></section></summary><div class="docblock"><p>Returns the concatenation of the given expressions.</p>
|
||
<p>This attempts to flatten and simplify the concatenation as appropriate.</p>
|
||
<h5 id="example-1"><a class="doc-anchor" href="#example-1">§</a>Example</h5>
|
||
<p>This shows a simple example of basic flattening of both concatenations
|
||
and literals.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::Hir;
|
||
|
||
<span class="kw">let </span>hir = Hir::concat(<span class="macro">vec!</span>[
|
||
Hir::concat(<span class="macro">vec!</span>[
|
||
Hir::literal([<span class="string">b'a'</span>]),
|
||
Hir::literal([<span class="string">b'b'</span>]),
|
||
Hir::literal([<span class="string">b'c'</span>]),
|
||
]),
|
||
Hir::concat(<span class="macro">vec!</span>[
|
||
Hir::literal([<span class="string">b'x'</span>]),
|
||
Hir::literal([<span class="string">b'y'</span>]),
|
||
Hir::literal([<span class="string">b'z'</span>]),
|
||
]),
|
||
]);
|
||
<span class="kw">let </span>expected = Hir::literal(<span class="string">"abcxyz"</span>.as_bytes());
|
||
<span class="macro">assert_eq!</span>(expected, hir);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.alternation" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#572-632">source</a><h4 class="code-header">pub fn <a href="#method.alternation" class="fn">alternation</a>(subs: <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a>>) -> <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h4></section></summary><div class="docblock"><p>Returns the alternation of the given expressions.</p>
|
||
<p>This flattens and simplifies the alternation as appropriate. This may
|
||
include factoring out common prefixes or even rewriting the alternation
|
||
as a character class.</p>
|
||
<p>Note that an empty alternation is equivalent to <code>Hir::fail()</code>. (It
|
||
is not possible for one to write an empty alternation, or even an
|
||
alternation with a single sub-expression, in the concrete syntax of a
|
||
regex.)</p>
|
||
<h5 id="example-2"><a class="doc-anchor" href="#example-2">§</a>Example</h5>
|
||
<p>This is a simple example showing how an alternation might get
|
||
simplified.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::{Hir, Class, ClassUnicode, ClassUnicodeRange};
|
||
|
||
<span class="kw">let </span>hir = Hir::alternation(<span class="macro">vec!</span>[
|
||
Hir::literal([<span class="string">b'a'</span>]),
|
||
Hir::literal([<span class="string">b'b'</span>]),
|
||
Hir::literal([<span class="string">b'c'</span>]),
|
||
Hir::literal([<span class="string">b'd'</span>]),
|
||
Hir::literal([<span class="string">b'e'</span>]),
|
||
Hir::literal([<span class="string">b'f'</span>]),
|
||
]);
|
||
<span class="kw">let </span>expected = Hir::class(Class::Unicode(ClassUnicode::new([
|
||
ClassUnicodeRange::new(<span class="string">'a'</span>, <span class="string">'f'</span>),
|
||
])));
|
||
<span class="macro">assert_eq!</span>(expected, hir);</code></pre></div>
|
||
<p>And another example showing how common prefixes might get factored
|
||
out.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::{Hir, Class, ClassUnicode, ClassUnicodeRange};
|
||
|
||
<span class="kw">let </span>hir = Hir::alternation(<span class="macro">vec!</span>[
|
||
Hir::concat(<span class="macro">vec!</span>[
|
||
Hir::literal(<span class="string">"abc"</span>.as_bytes()),
|
||
Hir::class(Class::Unicode(ClassUnicode::new([
|
||
ClassUnicodeRange::new(<span class="string">'A'</span>, <span class="string">'Z'</span>),
|
||
]))),
|
||
]),
|
||
Hir::concat(<span class="macro">vec!</span>[
|
||
Hir::literal(<span class="string">"abc"</span>.as_bytes()),
|
||
Hir::class(Class::Unicode(ClassUnicode::new([
|
||
ClassUnicodeRange::new(<span class="string">'a'</span>, <span class="string">'z'</span>),
|
||
]))),
|
||
]),
|
||
]);
|
||
<span class="kw">let </span>expected = Hir::concat(<span class="macro">vec!</span>[
|
||
Hir::literal(<span class="string">"abc"</span>.as_bytes()),
|
||
Hir::alternation(<span class="macro">vec!</span>[
|
||
Hir::class(Class::Unicode(ClassUnicode::new([
|
||
ClassUnicodeRange::new(<span class="string">'A'</span>, <span class="string">'Z'</span>),
|
||
]))),
|
||
Hir::class(Class::Unicode(ClassUnicode::new([
|
||
ClassUnicodeRange::new(<span class="string">'a'</span>, <span class="string">'z'</span>),
|
||
]))),
|
||
]),
|
||
]);
|
||
<span class="macro">assert_eq!</span>(expected, hir);</code></pre></div>
|
||
<p>Note that these sorts of simplifications are not guaranteed.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.dot" class="method"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#659-706">source</a><h4 class="code-header">pub fn <a href="#method.dot" class="fn">dot</a>(dot: <a class="enum" href="enum.Dot.html" title="enum regex_syntax::hir::Dot">Dot</a>) -> <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h4></section></summary><div class="docblock"><p>Returns an HIR expression for <code>.</code>.</p>
|
||
<ul>
|
||
<li><a href="enum.Dot.html#variant.AnyChar" title="variant regex_syntax::hir::Dot::AnyChar"><code>Dot::AnyChar</code></a> maps to <code>(?su-R:.)</code>.</li>
|
||
<li><a href="enum.Dot.html#variant.AnyByte" title="variant regex_syntax::hir::Dot::AnyByte"><code>Dot::AnyByte</code></a> maps to <code>(?s-Ru:.)</code>.</li>
|
||
<li><a href="enum.Dot.html#variant.AnyCharExceptLF" title="variant regex_syntax::hir::Dot::AnyCharExceptLF"><code>Dot::AnyCharExceptLF</code></a> maps to <code>(?u-Rs:.)</code>.</li>
|
||
<li><a href="enum.Dot.html#variant.AnyCharExceptCRLF" title="variant regex_syntax::hir::Dot::AnyCharExceptCRLF"><code>Dot::AnyCharExceptCRLF</code></a> maps to <code>(?Ru-s:.)</code>.</li>
|
||
<li><a href="enum.Dot.html#variant.AnyByteExceptLF" title="variant regex_syntax::hir::Dot::AnyByteExceptLF"><code>Dot::AnyByteExceptLF</code></a> maps to <code>(?-Rsu:.)</code>.</li>
|
||
<li><a href="enum.Dot.html#variant.AnyByteExceptCRLF" title="variant regex_syntax::hir::Dot::AnyByteExceptCRLF"><code>Dot::AnyByteExceptCRLF</code></a> maps to <code>(?R-su:.)</code>.</li>
|
||
</ul>
|
||
<h5 id="example-3"><a class="doc-anchor" href="#example-3">§</a>Example</h5>
|
||
<p>Note that this is a convenience routine for constructing the correct
|
||
character class based on the value of <code>Dot</code>. There is no explicit “dot”
|
||
HIR value. It is just an abbreviation for a common character class.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::{Hir, Dot, Class, ClassBytes, ClassBytesRange};
|
||
|
||
<span class="kw">let </span>hir = Hir::dot(Dot::AnyByte);
|
||
<span class="kw">let </span>expected = Hir::class(Class::Bytes(ClassBytes::new([
|
||
ClassBytesRange::new(<span class="number">0x00</span>, <span class="number">0xFF</span>),
|
||
])));
|
||
<span class="macro">assert_eq!</span>(expected, hir);</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-Hir" class="impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#204">source</a><a href="#impl-Clone-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</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_syntax/hir/mod.rs.html#204">source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&self) -> <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.80.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.80.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.80.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.80.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.80.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-Hir" class="impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#772-776">source</a><a href="#impl-Debug-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt-1" class="method trait-impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#773-775">source</a><a href="#method.fmt-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.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.80.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.80.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Display-for-Hir" class="impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#784-788">source</a><a href="#impl-Display-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section></summary><div class="docblock"><p>Print a display representation of this Hir.</p>
|
||
<p>The result of this is a valid regular expression pattern string.</p>
|
||
<p>This implementation uses constant stack space and heap space proportional
|
||
to the size of the <code>Hir</code>.</p>
|
||
</div><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_syntax/hir/mod.rs.html#785-787">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Display.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.80.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Drop-for-Hir" class="impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#1913-1953">source</a><a href="#impl-Drop-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section></summary><div class="docblock"><p>A custom <code>Drop</code> impl is used for <code>HirKind</code> such that it uses constant stack
|
||
space but heap space proportional to the depth of the total <code>Hir</code>.</p>
|
||
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.drop" class="method trait-impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#1914-1952">source</a><a href="#method.drop" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/ops/drop/trait.Drop.html#tymethod.drop" class="fn">drop</a>(&mut self)</h4></section></summary><div class='docblock'>Executes the destructor for this type. <a href="https://doc.rust-lang.org/1.80.0/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq-for-Hir" class="impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#204">source</a><a href="#impl-PartialEq-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#204">source</a><a href="#method.eq" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&self, other: &<a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
|
||
by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne" 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.80.0/src/core/cmp.rs.html#263">source</a></span><a href="#method.ne" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&Rhs</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always
|
||
sufficient, and should not be overridden without very good reason.</div></details></div></details><section id="impl-Eq-for-Hir" class="impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#204">source</a><a href="#impl-Eq-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section><section id="impl-StructuralPartialEq-for-Hir" class="impl"><a class="src rightside" href="../../src/regex_syntax/hir/mod.rs.html#204">source</a><a href="#impl-StructuralPartialEq-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.StructuralPartialEq.html" title="trait core::marker::StructuralPartialEq">StructuralPartialEq</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section></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-Freeze-for-Hir" class="impl"><a href="#impl-Freeze-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section><section id="impl-RefUnwindSafe-for-Hir" class="impl"><a href="#impl-RefUnwindSafe-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section><section id="impl-Send-for-Hir" class="impl"><a href="#impl-Send-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section><section id="impl-Sync-for-Hir" class="impl"><a href="#impl-Sync-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section><section id="impl-Unpin-for-Hir" class="impl"><a href="#impl-Unpin-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section><section id="impl-UnwindSafe-for-Hir" class="impl"><a href="#impl-UnwindSafe-for-Hir" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.80.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.80.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.80.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.80.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.80.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.80.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.80.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.80.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.80.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.80.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.80.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.80.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.80.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.80.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.80.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.80.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.80.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.80.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.80.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.80.0/src/core/convert/mod.rs.html#765">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.80.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.80.0/src/core/convert/mod.rs.html#768">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.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.80.0/src/core/convert/mod.rs.html#748-750">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.80.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.80.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.80.0/src/core/convert/mod.rs.html#758">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.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.80.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||
</div></details></div></details><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.80.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.80.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.80.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.80.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.80.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.80.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.80.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.80.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.80.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.80.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.80.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-ToString-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/alloc/string.rs.html#2552">source</a><a href="#impl-ToString-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.80.0/alloc/string/trait.ToString.html" title="trait alloc::string::ToString">ToString</a> for T<div class="where">where
|
||
T: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.80.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.to_string" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/alloc/string.rs.html#2558">source</a><a href="#method.to_string" class="anchor">§</a><h4 class="code-header">default fn <a href="https://doc.rust-lang.org/1.80.0/alloc/string/trait.ToString.html#tymethod.to_string" class="fn">to_string</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section></summary><div class='docblock'>Converts the given value to a <code>String</code>. <a href="https://doc.rust-lang.org/1.80.0/alloc/string/trait.ToString.html#tymethod.to_string">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.80.0/src/core/convert/mod.rs.html#805-807">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.80.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.80.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.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><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.80.0/src/core/convert/mod.rs.html#812">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.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.80.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.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><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.80.0/src/core/convert/mod.rs.html#790-792">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.80.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.80.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.80.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><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.80.0/src/core/convert/mod.rs.html#797">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.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.80.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.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html> |