| <!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."><meta name="keywords" content="rust, rustlang, rust-lang, Hir"><title>Hir in regex_syntax::hir - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.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><a class="sidebar-logo" href="../../regex_syntax/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../regex_syntax/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Hir</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><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"><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%3CHir%3E-for-Hir">PartialEq<Hir></a></li><li><a href="#impl-StructuralEq-for-Hir">StructuralEq</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"><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"><li><a href="#impl-Any-for-Hir">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-Hir">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-Hir">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-Hir">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-Hir">Into<U></a></li><li><a href="#impl-ToOwned-for-Hir">ToOwned</a></li><li><a href="#impl-ToString-for-Hir">ToString</a></li><li><a href="#impl-TryFrom%3CU%3E-for-Hir">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-Hir">TryInto<U></a></li></ul></section><h2><a href="index.html">In regex_syntax::hir</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">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" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/regex_syntax/hir/mod.rs.html#201-206">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct Hir { /* private fields */ }</code></pre></div><details class="rustdoc-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="HirKind"><code>HirKind</code></a> and a set of <a href="struct.Properties.html" title="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 href="#utf-8">UTF-8</a></h2> |
| <p>If the HIR was produced by a translator with |
| <a href="translate/struct.TranslatorBuilder.html#method.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 |
| repsonsibility 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 href="#stack-space">Stack space</a></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="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Hir" class="impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#209-236">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="rustdoc-toggle method-toggle" open><summary><section id="method.kind" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#211-213">source</a><h4 class="code-header">pub fn <a href="#method.kind" class="fnname">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="rustdoc-toggle method-toggle" open><summary><section id="method.into_kind" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#217-219">source</a><h4 class="code-header">pub fn <a href="#method.into_kind" class="fnname">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="rustdoc-toggle method-toggle" open><summary><section id="method.properties" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#222-224">source</a><h4 class="code-header">pub fn <a href="#method.properties" class="fnname">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="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Hir-1" class="impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#249-673">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="rustdoc-toggle method-toggle" open><summary><section id="method.empty" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#254-257">source</a><h4 class="code-header">pub fn <a href="#method.empty" class="fnname">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="rustdoc-toggle method-toggle" open><summary><section id="method.fail" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#275-282">source</a><h4 class="code-header">pub fn <a href="#method.fail" class="fnname">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="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="rustdoc-toggle method-toggle" open><summary><section id="method.literal" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#322-331">source</a><h4 class="code-header">pub fn <a href="#method.literal" class="fnname">literal</a><B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><[<a class="primitive" href="https://doc.rust-lang.org/nightly/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="Properties::is_utf8"><code>Properties::is_utf8</code></a>.</p> |
| <h5 id="example"><a href="#example">Example</a></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> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.class" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#339-347">source</a><h4 class="code-header">pub fn <a href="#method.class" class="fnname">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="rustdoc-toggle method-toggle" open><summary><section id="method.look" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#351-354">source</a><h4 class="code-header">pub fn <a href="#method.look" class="fnname">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="rustdoc-toggle method-toggle" open><summary><section id="method.repetition" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#358-371">source</a><h4 class="code-header">pub fn <a href="#method.repetition" class="fnname">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="rustdoc-toggle method-toggle" open><summary><section id="method.capture" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#381-384">source</a><h4 class="code-header">pub fn <a href="#method.capture" class="fnname">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="rustdoc-toggle method-toggle" open><summary><section id="method.concat" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#413-476">source</a><h4 class="code-header">pub fn <a href="#method.concat" class="fnname">concat</a>(subs: <a class="struct" href="https://doc.rust-lang.org/nightly/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 href="#example-1">Example</a></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="rustdoc-toggle method-toggle" open><summary><section id="method.alternation" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#546-606">source</a><h4 class="code-header">pub fn <a href="#method.alternation" class="fnname">alternation</a>(subs: <a class="struct" href="https://doc.rust-lang.org/nightly/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 href="#example-2">Example</a></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="rustdoc-toggle method-toggle" open><summary><section id="method.dot" class="method has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#633-672">source</a><h4 class="code-header">pub fn <a href="#method.dot" class="fnname">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="Dot::AnyChar"><code>Dot::AnyChar</code></a> maps to <code>(?su-R:.)</code>.</li> |
| <li><a href="enum.Dot.html#variant.AnyByte" title="Dot::AnyByte"><code>Dot::AnyByte</code></a> maps to <code>(?s-Ru:.)</code>.</li> |
| <li><a href="enum.Dot.html#variant.AnyCharExceptLF" title="Dot::AnyCharExceptLF"><code>Dot::AnyCharExceptLF</code></a> maps to <code>(?u-Rs:.)</code>.</li> |
| <li><a href="enum.Dot.html#variant.AnyCharExceptCRLF" title="Dot::AnyCharExceptCRLF"><code>Dot::AnyCharExceptCRLF</code></a> maps to <code>(?Ru-s:.)</code>.</li> |
| <li><a href="enum.Dot.html#variant.AnyByteExceptLF" title="Dot::AnyByteExceptLF"><code>Dot::AnyByteExceptLF</code></a> maps to <code>(?-Rsu:.)</code>.</li> |
| <li><a href="enum.Dot.html#variant.AnyByteExceptCRLF" title="Dot::AnyByteExceptCRLF"><code>Dot::AnyByteExceptCRLF</code></a> maps to <code>(?R-su:.)</code>.</li> |
| </ul> |
| <h5 id="example-3"><a href="#example-3">Example</a></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="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Clone-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#200">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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#200">source</a><a href="#method.clone" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> <a class="struct" href="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/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#132-134">source</a></span><a href="#method.clone_from" class="anchor"></a><h4 class="code-header">const fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#738-742">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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#739-741">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Display-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#750-754">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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.fmt-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#751-753">source</a><a href="#method.fmt-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Drop-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#1790-1830">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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.drop" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#1791-1829">source</a><a href="#method.drop" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop" class="fnname">drop</a>(&mut self)</h4></section></summary><div class='docblock'>Executes the destructor for this type. <a href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CHir%3E-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#200">source</a><a href="#impl-PartialEq%3CHir%3E-for-Hir" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a><<a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</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="rustdoc-toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#200">source</a><a href="#method.eq" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">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/nightly/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>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#227">source</a></span><a href="#method.ne" class="anchor"></a><h4 class="code-header">const fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/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. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne">Read more</a></div></details></div></details><section id="impl-Eq-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#200">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/nightly/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-StructuralEq-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#200">source</a><a href="#impl-StructuralEq-for-Hir" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.StructuralEq.html" title="trait core::marker::StructuralEq">StructuralEq</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 has-srclink"><a class="srclink rightside" href="../../src/regex_syntax/hir/mod.rs.html#200">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/nightly/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="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-Hir" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-Hir" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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 has-srclink"><a href="#impl-Send-for-Hir" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section><section id="impl-Sync-for-Hir" class="impl has-srclink"><a href="#impl-Sync-for-Hir" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section><section id="impl-Unpin-for-Hir" class="impl has-srclink"><a href="#impl-Unpin-for-Hir" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Hir.html" title="struct regex_syntax::hir::Hir">Hir</a></h3></section><section id="impl-UnwindSafe-for-Hir" class="impl has-srclink"><a href="#impl-UnwindSafe-for-Hir" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#200">source</a><a href="#impl-Any-for-Hir" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#201">source</a><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211">source</a><a href="#impl-Borrow%3CT%3E-for-Hir" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#213">source</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#220">source</a><a href="#impl-BorrowMut%3CT%3E-for-Hir" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#221">source</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#733">source</a><a href="#impl-From%3CT%3E-for-Hir" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#736">source</a></span><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#717">source</a><a href="#impl-Into%3CU%3E-for-Hir" class="anchor"></a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#725">source</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">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/nightly/core/convert/trait.From.html" title="From">From</a><T> for U</code> chooses to do.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToOwned-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#83">source</a><a href="#impl-ToOwned-for-Hir" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Owned" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/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/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">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/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/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/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToString-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2497">source</a><a href="#impl-ToString-for-Hir" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html" title="trait alloc::string::ToString">ToString</a> for T<span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_string" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2503">source</a><a href="#method.to_string" class="anchor"></a><h4 class="code-header">default fn <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string" class="fnname">to_string</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section></summary><div class='docblock'>Converts the given value to a <code>String</code>. <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#775">source</a><a href="#impl-TryFrom%3CU%3E-for-Hir" class="anchor"></a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#781">source</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-Hir" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#760">source</a><a href="#impl-TryInto%3CU%3E-for-Hir" class="anchor"></a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#766">source</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/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><div id="rustdoc-vars" data-root-path="../../" data-current-crate="regex_syntax" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html> |