| <!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 sequence of literals."><meta name="keywords" content="rust, rustlang, rust-lang, Seq"><title>Seq in regex_syntax::hir::literal - 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="#">Seq</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.cross_forward">cross_forward</a></li><li><a href="#method.cross_reverse">cross_reverse</a></li><li><a href="#method.dedup">dedup</a></li><li><a href="#method.empty">empty</a></li><li><a href="#method.infinite">infinite</a></li><li><a href="#method.is_empty">is_empty</a></li><li><a href="#method.is_exact">is_exact</a></li><li><a href="#method.is_finite">is_finite</a></li><li><a href="#method.is_inexact">is_inexact</a></li><li><a href="#method.keep_first_bytes">keep_first_bytes</a></li><li><a href="#method.keep_last_bytes">keep_last_bytes</a></li><li><a href="#method.len">len</a></li><li><a href="#method.literals">literals</a></li><li><a href="#method.longest_common_prefix">longest_common_prefix</a></li><li><a href="#method.longest_common_suffix">longest_common_suffix</a></li><li><a href="#method.make_inexact">make_inexact</a></li><li><a href="#method.make_infinite">make_infinite</a></li><li><a href="#method.max_literal_len">max_literal_len</a></li><li><a href="#method.min_literal_len">min_literal_len</a></li><li><a href="#method.minimize_by_preference">minimize_by_preference</a></li><li><a href="#method.new">new</a></li><li><a href="#method.optimize_for_prefix_by_preference">optimize_for_prefix_by_preference</a></li><li><a href="#method.optimize_for_suffix_by_preference">optimize_for_suffix_by_preference</a></li><li><a href="#method.push">push</a></li><li><a href="#method.reverse_literals">reverse_literals</a></li><li><a href="#method.singleton">singleton</a></li><li><a href="#method.sort">sort</a></li><li><a href="#method.union">union</a></li><li><a href="#method.union_into_empty">union_into_empty</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Clone-for-Seq">Clone</a></li><li><a href="#impl-Debug-for-Seq">Debug</a></li><li><a href="#impl-Eq-for-Seq">Eq</a></li><li><a href="#impl-FromIterator%3CLiteral%3E-for-Seq">FromIterator<Literal></a></li><li><a href="#impl-PartialEq%3CSeq%3E-for-Seq">PartialEq<Seq></a></li><li><a href="#impl-StructuralEq-for-Seq">StructuralEq</a></li><li><a href="#impl-StructuralPartialEq-for-Seq">StructuralPartialEq</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-Seq">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Seq">Send</a></li><li><a href="#impl-Sync-for-Seq">Sync</a></li><li><a href="#impl-Unpin-for-Seq">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Seq">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-Seq">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-Seq">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-Seq">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-Seq">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-Seq">Into<U></a></li><li><a href="#impl-ToOwned-for-Seq">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-Seq">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-Seq">TryInto<U></a></li></ul></section><h2><a href="index.html">In regex_syntax::hir::literal</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 href="index.html">literal</a>::<wbr><a class="struct" href="#">Seq</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/literal.rs.html#737-749">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 Seq { /* 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 sequence of literals.</p> |
| <p>A <code>Seq</code> is very much like a set in that it represents a union of its |
| members. That is, it corresponds to a set of literals where at least one |
| must match in order for a particular <a href="../struct.Hir.html" title="Hir"><code>Hir</code></a> expression to match. (Whether |
| this corresponds to the entire <code>Hir</code> expression, a prefix of it or a suffix |
| of it depends on how the <code>Seq</code> was extracted from the <code>Hir</code>.)</p> |
| <p>It is also unlike a set in that multiple identical literals may appear, |
| and that the order of the literals in the <code>Seq</code> matters. For example, if |
| the sequence is <code>[sam, samwise]</code> and leftmost-first matching is used, then |
| <code>samwise</code> can never match and the sequence is equivalent to <code>[sam]</code>.</p> |
| <h2 id="states-of-a-sequence"><a href="#states-of-a-sequence">States of a sequence</a></h2> |
| <p>A <code>Seq</code> has a few different logical states to consider:</p> |
| <ul> |
| <li>The sequence can represent “any” literal. When this happens, the set does |
| not have a finite size. The purpose of this state is to inhibit callers |
| from making assumptions about what literals are required in order to match |
| a particular <a href="../struct.Hir.html" title="Hir"><code>Hir</code></a> expression. Generally speaking, when a set is in this |
| state, literal optimizations are inhibited. A good example of a regex that |
| will cause this sort of set to apppear is <code>[A-Za-z]</code>. The character class |
| is just too big (and also too narrow) to be usefully expanded into 52 |
| different literals. (Note that the decision for when a seq should become |
| infinite is determined by the caller. A seq itself has no hard-coded |
| limits.)</li> |
| <li>The sequence can be empty, in which case, it is an affirmative statement |
| that there are no literals that can match the corresponding <code>Hir</code>. |
| Consequently, the <code>Hir</code> never matches any input. For example, <code>[a&&b]</code>.</li> |
| <li>The sequence can be non-empty, in which case, at least one of the |
| literals must match in order for the corresponding <code>Hir</code> to match.</li> |
| </ul> |
| <h2 id="example"><a href="#example">Example</a></h2> |
| <p>This example shows how literal sequences can be simplified by stripping |
| suffixes and minimizing while maintaining preference order.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[ |
| <span class="string">"farm"</span>, |
| <span class="string">"appliance"</span>, |
| <span class="string">"faraway"</span>, |
| <span class="string">"apple"</span>, |
| <span class="string">"fare"</span>, |
| <span class="string">"gap"</span>, |
| <span class="string">"applicant"</span>, |
| <span class="string">"applaud"</span>, |
| ]); |
| seq.keep_first_bytes(<span class="number">3</span>); |
| seq.minimize_by_preference(); |
| <span class="comment">// Notice that 'far' comes before 'app', which matches the order in the |
| // original sequence. This guarantees that leftmost-first semantics are |
| // not altered by simplifying the set. |
| </span><span class="kw">let </span>expected = Seq::from_iter([ |
| Literal::inexact(<span class="string">"far"</span>), |
| Literal::inexact(<span class="string">"app"</span>), |
| Literal::exact(<span class="string">"gap"</span>), |
| ]); |
| <span class="macro">assert_eq!</span>(expected, seq);</code></pre></div> |
| </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-Seq" class="impl has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#751-1972">source</a><a href="#impl-Seq" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h3></section></summary><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/literal.rs.html#757-759">source</a><h4 class="code-header">pub fn <a href="#method.empty" class="fnname">empty</a>() -> <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h4></section></summary><div class="docblock"><p>Returns an empty sequence.</p> |
| <p>An empty sequence matches zero literals, and thus corresponds to a |
| regex that itself can never match.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.infinite" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#780-782">source</a><h4 class="code-header">pub fn <a href="#method.infinite" class="fnname">infinite</a>() -> <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h4></section></summary><div class="docblock"><p>Returns a sequence of literals without a finite size and may contain |
| any literal.</p> |
| <p>A sequence without finite size does not reveal anything about the |
| characteristics of the literals in its set. There are no fixed prefixes |
| or suffixes, nor are lower or upper bounds on the length of the literals |
| in the set known.</p> |
| <p>This is useful to represent constructs in a regex that are “too big” |
| to useful represent as a sequence of literals. For example, <code>[A-Za-z]</code>. |
| When sequences get too big, they lose their discriminating nature and |
| are more likely to produce false positives, which in turn makes them |
| less likely to speed up searches.</p> |
| <p>More pragmatically, for many regexes, enumerating all possible literals |
| is itself not possible or might otherwise use too many resources. So |
| constraining the size of sets during extraction is a practical trade |
| off to make.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.singleton" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#786-788">source</a><h4 class="code-header">pub fn <a href="#method.singleton" class="fnname">singleton</a>(lit: <a class="struct" href="struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a>) -> <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h4></section></summary><div class="docblock"><p>Returns a sequence containing a single literal.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#792-798">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a><I, B>(it: I) -> <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a><span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a><Item = B>,<br> B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]>,</span></h4></section></summary><div class="docblock"><p>Returns a sequence of exact literals from the given byte strings.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.literals" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#806-808">source</a><h4 class="code-header">pub fn <a href="#method.literals" class="fnname">literals</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&[<a class="struct" href="struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a>]></h4></section></summary><div class="docblock"><p>If this is a finite sequence, return its members as a slice of |
| literals.</p> |
| <p>The slice returned may be empty, in which case, there are no literals |
| that can match this sequence.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.push" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#821-830">source</a><h4 class="code-header">pub fn <a href="#method.push" class="fnname">push</a>(&mut self, lit: <a class="struct" href="struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a>)</h4></section></summary><div class="docblock"><p>Push a literal to the end of this sequence.</p> |
| <p>If this sequence is not finite, then this is a no-op.</p> |
| <p>Similarly, if the most recently added item of this sequence is |
| equivalent to the literal given, then it is not added. This reflects |
| a <code>Seq</code>’s “set like” behavior, and represents a practical trade off. |
| Namely, there is never any need to have two adjacent and equivalent |
| literals in the same sequence, <em>and</em> it is easy to detect in some |
| cases.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.make_inexact" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#836-844">source</a><h4 class="code-header">pub fn <a href="#method.make_inexact" class="fnname">make_inexact</a>(&mut self)</h4></section></summary><div class="docblock"><p>Make all of the literals in this sequence inexact.</p> |
| <p>This is a no-op if this sequence is not finite.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.make_infinite" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#850-852">source</a><h4 class="code-header">pub fn <a href="#method.make_infinite" class="fnname">make_infinite</a>(&mut self)</h4></section></summary><div class="docblock"><p>Converts this sequence to an infinite sequence.</p> |
| <p>This is a no-op if the sequence is already infinite.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cross_forward" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#963-988">source</a><h4 class="code-header">pub fn <a href="#method.cross_forward" class="fnname">cross_forward</a>(&mut self, other: &mut <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a>)</h4></section></summary><div class="docblock"><p>Modify this sequence to contain the cross product between it and the |
| sequence given.</p> |
| <p>The cross product only considers literals in this sequence that are |
| exact. That is, inexact literals are not extended.</p> |
| <p>The literals are always drained from <code>other</code>, even if none are used. |
| This permits callers to reuse the sequence allocation elsewhere.</p> |
| <p>If this sequence is infinite, then this is a no-op, regardless of what |
| <code>other</code> contains (and in this case, the literals are still drained from |
| <code>other</code>). If <code>other</code> is infinite and this sequence is finite, then this |
| is a no-op, unless this sequence contains a zero-length literal. In |
| which case, the infiniteness of <code>other</code> infects this sequence, and this |
| sequence is itself made infinite.</p> |
| <p>Like <a href="struct.Seq.html#method.union" title="Seq::union"><code>Seq::union</code></a>, this may attempt to deduplicate literals. See |
| <a href="struct.Seq.html#method.dedup" title="Seq::dedup"><code>Seq::dedup</code></a> for how deduplication deals with exact and inexact |
| literals.</p> |
| <h5 id="example-1"><a href="#example-1">Example</a></h5> |
| <p>This example shows basic usage and how exact and inexact literals |
| interact.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::from_iter([ |
| Literal::exact(<span class="string">"foo"</span>), |
| Literal::inexact(<span class="string">"bar"</span>), |
| ]); |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::from_iter([ |
| Literal::inexact(<span class="string">"quux"</span>), |
| Literal::exact(<span class="string">"baz"</span>), |
| ]); |
| seq1.cross_forward(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// The literals are pulled out of seq2. |
| </span><span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">0</span>), seq2.len()); |
| |
| <span class="kw">let </span>expected = Seq::from_iter([ |
| Literal::inexact(<span class="string">"fooquux"</span>), |
| Literal::exact(<span class="string">"foobaz"</span>), |
| Literal::inexact(<span class="string">"bar"</span>), |
| ]); |
| <span class="macro">assert_eq!</span>(expected, seq1);</code></pre></div> |
| <p>This example shows the behavior of when <code>other</code> is an infinite |
| sequence.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::from_iter([ |
| Literal::exact(<span class="string">"foo"</span>), |
| Literal::inexact(<span class="string">"bar"</span>), |
| ]); |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::infinite(); |
| seq1.cross_forward(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// When seq2 is infinite, cross product doesn't add anything, but |
| // ensures all members of seq1 are inexact. |
| </span><span class="kw">let </span>expected = Seq::from_iter([ |
| Literal::inexact(<span class="string">"foo"</span>), |
| Literal::inexact(<span class="string">"bar"</span>), |
| ]); |
| <span class="macro">assert_eq!</span>(expected, seq1);</code></pre></div> |
| <p>This example is like the one above, but shows what happens when this |
| sequence contains an empty string. In this case, an infinite <code>other</code> |
| sequence infects this sequence (because the empty string means that |
| there are no finite prefixes):</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::from_iter([ |
| Literal::exact(<span class="string">"foo"</span>), |
| Literal::exact(<span class="string">""</span>), <span class="comment">// inexact provokes same behavior |
| </span>Literal::inexact(<span class="string">"bar"</span>), |
| ]); |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::infinite(); |
| seq1.cross_forward(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// seq1 is now infinite! |
| </span><span class="macro">assert!</span>(!seq1.is_finite());</code></pre></div> |
| <p>This example shows the behavior of this sequence is infinite.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::infinite(); |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::from_iter([ |
| Literal::exact(<span class="string">"foo"</span>), |
| Literal::inexact(<span class="string">"bar"</span>), |
| ]); |
| seq1.cross_forward(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// seq1 remains unchanged. |
| </span><span class="macro">assert!</span>(!seq1.is_finite()); |
| <span class="comment">// Even though the literals in seq2 weren't used, it was still drained. |
| </span><span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">0</span>), seq2.len());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cross_reverse" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1102-1138">source</a><h4 class="code-header">pub fn <a href="#method.cross_reverse" class="fnname">cross_reverse</a>(&mut self, other: &mut <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a>)</h4></section></summary><div class="docblock"><p>Modify this sequence to contain the cross product between it and |
| the sequence given, where the sequences are treated as suffixes |
| instead of prefixes. Namely, the sequence <code>other</code> is <em>prepended</em> |
| to <code>self</code> (as opposed to <code>other</code> being <em>appended</em> to <code>self</code> in |
| <a href="struct.Seq.html#method.cross_forward" title="Seq::cross_forward"><code>Seq::cross_forward</code></a>).</p> |
| <p>The cross product only considers literals in this sequence that are |
| exact. That is, inexact literals are not extended.</p> |
| <p>The literals are always drained from <code>other</code>, even if none are used. |
| This permits callers to reuse the sequence allocation elsewhere.</p> |
| <p>If this sequence is infinite, then this is a no-op, regardless of what |
| <code>other</code> contains (and in this case, the literals are still drained from |
| <code>other</code>). If <code>other</code> is infinite and this sequence is finite, then this |
| is a no-op, unless this sequence contains a zero-length literal. In |
| which case, the infiniteness of <code>other</code> infects this sequence, and this |
| sequence is itself made infinite.</p> |
| <p>Like <a href="struct.Seq.html#method.union" title="Seq::union"><code>Seq::union</code></a>, this may attempt to deduplicate literals. See |
| <a href="struct.Seq.html#method.dedup" title="Seq::dedup"><code>Seq::dedup</code></a> for how deduplication deals with exact and inexact |
| literals.</p> |
| <h5 id="example-2"><a href="#example-2">Example</a></h5> |
| <p>This example shows basic usage and how exact and inexact literals |
| interact.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::from_iter([ |
| Literal::exact(<span class="string">"foo"</span>), |
| Literal::inexact(<span class="string">"bar"</span>), |
| ]); |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::from_iter([ |
| Literal::inexact(<span class="string">"quux"</span>), |
| Literal::exact(<span class="string">"baz"</span>), |
| ]); |
| seq1.cross_reverse(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// The literals are pulled out of seq2. |
| </span><span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">0</span>), seq2.len()); |
| |
| <span class="kw">let </span>expected = Seq::from_iter([ |
| Literal::inexact(<span class="string">"quuxfoo"</span>), |
| Literal::inexact(<span class="string">"bar"</span>), |
| Literal::exact(<span class="string">"bazfoo"</span>), |
| ]); |
| <span class="macro">assert_eq!</span>(expected, seq1);</code></pre></div> |
| <p>This example shows the behavior of when <code>other</code> is an infinite |
| sequence.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::from_iter([ |
| Literal::exact(<span class="string">"foo"</span>), |
| Literal::inexact(<span class="string">"bar"</span>), |
| ]); |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::infinite(); |
| seq1.cross_reverse(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// When seq2 is infinite, cross product doesn't add anything, but |
| // ensures all members of seq1 are inexact. |
| </span><span class="kw">let </span>expected = Seq::from_iter([ |
| Literal::inexact(<span class="string">"foo"</span>), |
| Literal::inexact(<span class="string">"bar"</span>), |
| ]); |
| <span class="macro">assert_eq!</span>(expected, seq1);</code></pre></div> |
| <p>This example is like the one above, but shows what happens when this |
| sequence contains an empty string. In this case, an infinite <code>other</code> |
| sequence infects this sequence (because the empty string means that |
| there are no finite suffixes):</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::from_iter([ |
| Literal::exact(<span class="string">"foo"</span>), |
| Literal::exact(<span class="string">""</span>), <span class="comment">// inexact provokes same behavior |
| </span>Literal::inexact(<span class="string">"bar"</span>), |
| ]); |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::infinite(); |
| seq1.cross_reverse(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// seq1 is now infinite! |
| </span><span class="macro">assert!</span>(!seq1.is_finite());</code></pre></div> |
| <p>This example shows the behavior when this sequence is infinite.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::infinite(); |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::from_iter([ |
| Literal::exact(<span class="string">"foo"</span>), |
| Literal::inexact(<span class="string">"bar"</span>), |
| ]); |
| seq1.cross_reverse(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// seq1 remains unchanged. |
| </span><span class="macro">assert!</span>(!seq1.is_finite()); |
| <span class="comment">// Even though the literals in seq2 weren't used, it was still drained. |
| </span><span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">0</span>), seq2.len());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.union" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1223-1239">source</a><h4 class="code-header">pub fn <a href="#method.union" class="fnname">union</a>(&mut self, other: &mut <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a>)</h4></section></summary><div class="docblock"><p>Unions the <code>other</code> sequence into this one.</p> |
| <p>The literals are always drained out of the given <code>other</code> sequence, |
| even if they are being unioned into an infinite sequence. This permits |
| the caller to reuse the <code>other</code> sequence in another context.</p> |
| <p>Some literal deduping may be performed. If any deduping happens, |
| any leftmost-first or “preference” order match semantics will be |
| preserved.</p> |
| <h5 id="example-3"><a href="#example-3">Example</a></h5> |
| <p>This example shows basic usage.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::Seq; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>]); |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::new(<span class="kw-2">&</span>[<span class="string">"bar"</span>, <span class="string">"quux"</span>, <span class="string">"foo"</span>]); |
| seq1.union(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// The literals are pulled out of seq2. |
| </span><span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">0</span>), seq2.len()); |
| |
| <span class="comment">// Adjacent literals are deduped, but non-adjacent literals may not be. |
| </span><span class="macro">assert_eq!</span>(Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>, <span class="string">"quux"</span>, <span class="string">"foo"</span>]), seq1);</code></pre></div> |
| <p>This example shows that literals are drained from <code>other</code> even when |
| they aren’t necessarily used.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::Seq; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::infinite(); |
| <span class="comment">// Infinite sequences have no finite length. |
| </span><span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, seq1.len()); |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::new(<span class="kw-2">&</span>[<span class="string">"bar"</span>, <span class="string">"quux"</span>, <span class="string">"foo"</span>]); |
| seq1.union(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// seq1 is still infinite and seq2 has been drained. |
| </span><span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, seq1.len()); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">0</span>), seq2.len());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.union_into_empty" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1291-1318">source</a><h4 class="code-header">pub fn <a href="#method.union_into_empty" class="fnname">union_into_empty</a>(&mut self, other: &mut <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a>)</h4></section></summary><div class="docblock"><p>Unions the <code>other</code> sequence into this one by splice the <code>other</code> |
| sequence at the position of the first zero-length literal.</p> |
| <p>This is useful for preserving preference order semantics when combining |
| two literal sequences. For example, in the regex <code>(a||f)+foo</code>, the |
| correct preference order prefix sequence is <code>[a, foo, f]</code>.</p> |
| <p>The literals are always drained out of the given <code>other</code> sequence, |
| even if they are being unioned into an infinite sequence. This permits |
| the caller to reuse the <code>other</code> sequence in another context. Note that |
| the literals are drained even if no union is performed as well, i.e., |
| when this sequence does not contain a zero-length literal.</p> |
| <p>Some literal deduping may be performed. If any deduping happens, |
| any leftmost-first or “preference” order match semantics will be |
| preserved.</p> |
| <h5 id="example-4"><a href="#example-4">Example</a></h5> |
| <p>This example shows basic usage.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::Seq; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::new(<span class="kw-2">&</span>[<span class="string">"a"</span>, <span class="string">""</span>, <span class="string">"f"</span>, <span class="string">""</span>]); |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>]); |
| seq1.union_into_empty(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// The literals are pulled out of seq2. |
| </span><span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">0</span>), seq2.len()); |
| <span class="comment">// 'foo' gets spliced into seq1 where the first empty string occurs. |
| </span><span class="macro">assert_eq!</span>(Seq::new(<span class="kw-2">&</span>[<span class="string">"a"</span>, <span class="string">"foo"</span>, <span class="string">"f"</span>]), seq1);</code></pre></div> |
| <p>This example shows that literals are drained from <code>other</code> even when |
| they aren’t necessarily used.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::Seq; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq1 = Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>]); |
| <span class="kw">let </span><span class="kw-2">mut </span>seq2 = Seq::new(<span class="kw-2">&</span>[<span class="string">"bar"</span>, <span class="string">"quux"</span>, <span class="string">"foo"</span>]); |
| seq1.union_into_empty(<span class="kw-2">&mut </span>seq2); |
| |
| <span class="comment">// seq1 has no zero length literals, so no splicing happens. |
| </span><span class="macro">assert_eq!</span>(Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>]), seq1); |
| <span class="comment">// Even though no splicing happens, seq2 is still drained. |
| </span><span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="number">0</span>), seq2.len());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.dedup" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1345-1358">source</a><h4 class="code-header">pub fn <a href="#method.dedup" class="fnname">dedup</a>(&mut self)</h4></section></summary><div class="docblock"><p>Deduplicate adjacent equivalent literals in this sequence.</p> |
| <p>If adjacent literals are equivalent strings but one is exact and the |
| other inexact, the inexact literal is kept and the exact one is |
| removed.</p> |
| <p>Deduping an infinite sequence is a no-op.</p> |
| <h5 id="example-5"><a href="#example-5">Example</a></h5> |
| <p>This example shows how literals that are duplicate byte strings but |
| are not equivalent with respect to exactness are resolved.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::from_iter([ |
| Literal::exact(<span class="string">"foo"</span>), |
| Literal::inexact(<span class="string">"foo"</span>), |
| ]); |
| seq.dedup(); |
| |
| <span class="macro">assert_eq!</span>(Seq::from_iter([Literal::inexact(<span class="string">"foo"</span>)]), seq);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sort" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1382-1386">source</a><h4 class="code-header">pub fn <a href="#method.sort" class="fnname">sort</a>(&mut self)</h4></section></summary><div class="docblock"><p>Sorts this sequence of literals lexicographically.</p> |
| <p>Note that if, before sorting, if a literal that is a prefix of another |
| literal appears after it, then after sorting, the sequence will not |
| represent the same preference order match semantics. For example, |
| sorting the sequence <code>[samwise, sam]</code> yields the sequence <code>[sam, samwise]</code>. Under preference order semantics, the latter sequence will |
| never match <code>samwise</code> where as the first sequence can.</p> |
| <h5 id="example-6"><a href="#example-6">Example</a></h5> |
| <p>This example shows basic usage.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::Seq; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"quux"</span>, <span class="string">"bar"</span>]); |
| seq.sort(); |
| |
| <span class="macro">assert_eq!</span>(Seq::new(<span class="kw-2">&</span>[<span class="string">"bar"</span>, <span class="string">"foo"</span>, <span class="string">"quux"</span>]), seq);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.reverse_literals" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1404-1410">source</a><h4 class="code-header">pub fn <a href="#method.reverse_literals" class="fnname">reverse_literals</a>(&mut self)</h4></section></summary><div class="docblock"><p>Reverses all of the literals in this sequence.</p> |
| <p>The order of the sequence itself is preserved.</p> |
| <h5 id="example-7"><a href="#example-7">Example</a></h5> |
| <p>This example shows basic usage.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::Seq; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"oof"</span>, <span class="string">"rab"</span>]); |
| seq.reverse_literals(); |
| <span class="macro">assert_eq!</span>(Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>]), seq);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.minimize_by_preference" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1467-1471">source</a><h4 class="code-header">pub fn <a href="#method.minimize_by_preference" class="fnname">minimize_by_preference</a>(&mut self)</h4></section></summary><div class="docblock"><p>Shrinks this seq to its minimal size while respecting the preference |
| order of its literals.</p> |
| <p>While this routine will remove duplicate literals from this seq, it |
| will also remove literals that can never match in a leftmost-first or |
| “preference order” search. Similar to <a href="struct.Seq.html#method.dedup" title="Seq::dedup"><code>Seq::dedup</code></a>, if a literal is |
| deduped, then the one that remains is made inexact.</p> |
| <p>This is a no-op on seqs that are empty or not finite.</p> |
| <h5 id="example-8"><a href="#example-8">Example</a></h5> |
| <p>This example shows the difference between <code>{sam, samwise}</code> and |
| <code>{samwise, sam}</code>.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="comment">// If 'sam' comes before 'samwise' and a preference order search is |
| // executed, then 'samwise' can never match. |
| </span><span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"sam"</span>, <span class="string">"samwise"</span>]); |
| seq.minimize_by_preference(); |
| <span class="macro">assert_eq!</span>(Seq::from_iter([Literal::inexact(<span class="string">"sam"</span>)]), seq); |
| |
| <span class="comment">// But if they are reversed, then it's possible for 'samwise' to match |
| // since it is given higher preference. |
| </span><span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"samwise"</span>, <span class="string">"sam"</span>]); |
| seq.minimize_by_preference(); |
| <span class="macro">assert_eq!</span>(Seq::new(<span class="kw-2">&</span>[<span class="string">"samwise"</span>, <span class="string">"sam"</span>]), seq);</code></pre></div> |
| <p>This example shows that if an empty string is in this seq, then |
| anything that comes after it can never match.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="comment">// An empty string is a prefix of all strings, so it automatically |
| // inhibits any subsequent strings from matching. |
| </span><span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>, <span class="string">""</span>, <span class="string">"quux"</span>, <span class="string">"fox"</span>]); |
| seq.minimize_by_preference(); |
| <span class="kw">let </span>expected = Seq::from_iter([ |
| Literal::exact(<span class="string">"foo"</span>), |
| Literal::exact(<span class="string">"bar"</span>), |
| Literal::inexact(<span class="string">""</span>), |
| ]); |
| <span class="macro">assert_eq!</span>(expected, seq); |
| |
| <span class="comment">// And of course, if it's at the beginning, then it makes it impossible |
| // for anything else to match. |
| </span><span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">""</span>, <span class="string">"foo"</span>, <span class="string">"quux"</span>, <span class="string">"fox"</span>]); |
| seq.minimize_by_preference(); |
| <span class="macro">assert_eq!</span>(Seq::from_iter([Literal::inexact(<span class="string">""</span>)]), seq);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.keep_first_bytes" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1493-1499">source</a><h4 class="code-header">pub fn <a href="#method.keep_first_bytes" class="fnname">keep_first_bytes</a>(&mut self, len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</h4></section></summary><div class="docblock"><p>Trims all literals in this seq such that only the first <code>len</code> bytes |
| remain. If a literal has less than or equal to <code>len</code> bytes, then it |
| remains unchanged. Otherwise, it is trimmed and made inexact.</p> |
| <h5 id="example-9"><a href="#example-9">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"a"</span>, <span class="string">"foo"</span>, <span class="string">"quux"</span>]); |
| seq.keep_first_bytes(<span class="number">2</span>); |
| |
| <span class="kw">let </span>expected = Seq::from_iter([ |
| Literal::exact(<span class="string">"a"</span>), |
| Literal::inexact(<span class="string">"fo"</span>), |
| Literal::inexact(<span class="string">"qu"</span>), |
| ]); |
| <span class="macro">assert_eq!</span>(expected, seq);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.keep_last_bytes" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1521-1527">source</a><h4 class="code-header">pub fn <a href="#method.keep_last_bytes" class="fnname">keep_last_bytes</a>(&mut self, len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</h4></section></summary><div class="docblock"><p>Trims all literals in this seq such that only the last <code>len</code> bytes |
| remain. If a literal has less than or equal to <code>len</code> bytes, then it |
| remains unchanged. Otherwise, it is trimmed and made inexact.</p> |
| <h5 id="example-10"><a href="#example-10">Example</a></h5> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Literal, Seq}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"a"</span>, <span class="string">"foo"</span>, <span class="string">"quux"</span>]); |
| seq.keep_last_bytes(<span class="number">2</span>); |
| |
| <span class="kw">let </span>expected = Seq::from_iter([ |
| Literal::exact(<span class="string">"a"</span>), |
| Literal::inexact(<span class="string">"oo"</span>), |
| Literal::inexact(<span class="string">"ux"</span>), |
| ]); |
| <span class="macro">assert_eq!</span>(expected, seq);</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_finite" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1534-1536">source</a><h4 class="code-header">pub fn <a href="#method.is_finite" class="fnname">is_finite</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns true if this sequence is finite.</p> |
| <p>When false, this sequence is infinite and must be treated as if it |
| contains every possible literal.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_empty" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1543-1545">source</a><h4 class="code-header">pub fn <a href="#method.is_empty" class="fnname">is_empty</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns true if and only if this sequence is finite and empty.</p> |
| <p>An empty sequence never matches anything. It can only be produced by |
| literal extraction when the corresponding regex itself cannot match.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.len" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1550-1552">source</a><h4 class="code-header">pub fn <a href="#method.len" class="fnname">len</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Returns the number of literals in this sequence if the sequence is |
| finite. If the sequence is infinite, then <code>None</code> is returned.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_exact" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1558-1560">source</a><h4 class="code-header">pub fn <a href="#method.is_exact" class="fnname">is_exact</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns true if and only if all literals in this sequence are exact.</p> |
| <p>This returns false if the sequence is infinite.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_inexact" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1566-1568">source</a><h4 class="code-header">pub fn <a href="#method.is_inexact" class="fnname">is_inexact</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns true if and only if all literals in this sequence are inexact.</p> |
| <p>This returns true if the sequence is infinite.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.min_literal_len" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1594-1596">source</a><h4 class="code-header">pub fn <a href="#method.min_literal_len" class="fnname">min_literal_len</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Returns the length of the shortest literal in this sequence.</p> |
| <p>If the sequence is infinite or empty, then this returns <code>None</code>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.max_literal_len" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1602-1604">source</a><h4 class="code-header">pub fn <a href="#method.max_literal_len" class="fnname">max_literal_len</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Returns the length of the longest literal in this sequence.</p> |
| <p>If the sequence is infinite or empty, then this returns <code>None</code>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.longest_common_prefix" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1633-1657">source</a><h4 class="code-header">pub fn <a href="#method.longest_common_prefix" class="fnname">longest_common_prefix</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]></h4></section></summary><div class="docblock"><p>Returns the longest common prefix from this seq.</p> |
| <p>If the seq matches any literal or other contains no literals, then |
| there is no meaningful prefix and this returns <code>None</code>.</p> |
| <h5 id="example-11"><a href="#example-11">Example</a></h5> |
| <p>This shows some example seqs and their longest common prefix.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::Seq; |
| |
| <span class="kw">let </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"foobar"</span>, <span class="string">"fo"</span>]); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b"fo"</span>[..]), seq.longest_common_prefix()); |
| <span class="kw">let </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"foo"</span>]); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b"foo"</span>[..]), seq.longest_common_prefix()); |
| <span class="kw">let </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>]); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b""</span>[..]), seq.longest_common_prefix()); |
| <span class="kw">let </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">""</span>]); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b""</span>[..]), seq.longest_common_prefix()); |
| |
| <span class="kw">let </span>seq = Seq::infinite(); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, seq.longest_common_prefix()); |
| <span class="kw">let </span>seq = Seq::empty(); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, seq.longest_common_prefix());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.longest_common_suffix" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1686-1711">source</a><h4 class="code-header">pub fn <a href="#method.longest_common_suffix" class="fnname">longest_common_suffix</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]></h4></section></summary><div class="docblock"><p>Returns the longest common suffix from this seq.</p> |
| <p>If the seq matches any literal or other contains no literals, then |
| there is no meaningful suffix and this returns <code>None</code>.</p> |
| <h5 id="example-12"><a href="#example-12">Example</a></h5> |
| <p>This shows some example seqs and their longest common suffix.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::Seq; |
| |
| <span class="kw">let </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"oof"</span>, <span class="string">"raboof"</span>, <span class="string">"of"</span>]); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b"of"</span>[..]), seq.longest_common_suffix()); |
| <span class="kw">let </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"foo"</span>]); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b"foo"</span>[..]), seq.longest_common_suffix()); |
| <span class="kw">let </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">"foo"</span>, <span class="string">"bar"</span>]); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b""</span>[..]), seq.longest_common_suffix()); |
| <span class="kw">let </span>seq = Seq::new(<span class="kw-2">&</span>[<span class="string">""</span>]); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="string">b""</span>[..]), seq.longest_common_suffix()); |
| |
| <span class="kw">let </span>seq = Seq::infinite(); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, seq.longest_common_suffix()); |
| <span class="kw">let </span>seq = Seq::empty(); |
| <span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, seq.longest_common_suffix());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.optimize_for_prefix_by_preference" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1823-1825">source</a><h4 class="code-header">pub fn <a href="#method.optimize_for_prefix_by_preference" class="fnname">optimize_for_prefix_by_preference</a>(&mut self)</h4></section></summary><div class="docblock"><p>Optimizes this seq while treating its literals as prefixes and |
| respecting the preference order of its literals.</p> |
| <p>The specific way “optimization” works is meant to be an implementation |
| detail, as it essentially represents a set of heuristics. The goal |
| that optimization tries to accomplish is to make the literals in this |
| set reflect inputs that will result in a more effective prefilter. |
| Principally by reducing the false positive rate of candidates found by |
| the literals in this sequence. That is, when a match of a literal is |
| found, we would like it to be a strong predictor of the overall match |
| of the regex. If it isn’t, then much time will be spent starting and |
| stopping the prefilter search and attempting to confirm the match only |
| to have it fail.</p> |
| <p>Some of those heuristics might be:</p> |
| <ul> |
| <li>Identifying a common prefix from a larger sequence of literals, and |
| shrinking the sequence down to that single common prefix.</li> |
| <li>Rejecting the sequence entirely if it is believed to result in very |
| high false positive rate. When this happens, the sequence is made |
| infinite.</li> |
| <li>Shrinking the sequence to a smaller number of literals representing |
| prefixes, but not shrinking it so much as to make literals too short. |
| (A sequence with very short literals, of 1 or 2 bytes, will typically |
| result in a higher false positive rate.)</li> |
| </ul> |
| <p>Optimization should only be run once extraction is complete. Namely, |
| optimization may make assumptions that do not compose with other |
| operations in the middle of extraction. For example, optimization will |
| reduce <code>[E(sam), E(samwise)]</code> to <code>[E(sam)]</code>, but such a transformation |
| is only valid if no other extraction will occur. If other extraction |
| may occur, then the correct transformation would be to <code>[I(sam)]</code>.</p> |
| <p>The <a href="struct.Seq.html#method.optimize_for_suffix_by_preference" title="Seq::optimize_for_suffix_by_preference"><code>Seq::optimize_for_suffix_by_preference</code></a> does the same thing, but |
| for suffixes.</p> |
| <h5 id="example-13"><a href="#example-13">Example</a></h5> |
| <p>This shows how optimization might transform a sequence. Note that |
| the specific behavior is not a documented guarantee. The heuristics |
| used are an implementation detail and may change over time in semver |
| compatible releases.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Seq, Literal}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[ |
| <span class="string">"samantha"</span>, |
| <span class="string">"sam"</span>, |
| <span class="string">"samwise"</span>, |
| <span class="string">"frodo"</span>, |
| ]); |
| seq.optimize_for_prefix_by_preference(); |
| <span class="macro">assert_eq!</span>(Seq::from_iter([ |
| Literal::exact(<span class="string">"samantha"</span>), |
| <span class="comment">// Kept exact even though 'samwise' got pruned |
| // because optimization assumes literal extraction |
| // has finished. |
| </span>Literal::exact(<span class="string">"sam"</span>), |
| Literal::exact(<span class="string">"frodo"</span>), |
| ]), seq);</code></pre></div> |
| <h5 id="example-optimization-may-make-the-sequence-infinite"><a href="#example-optimization-may-make-the-sequence-infinite">Example: optimization may make the sequence infinite</a></h5> |
| <p>If the heuristics deem that the sequence could cause a very high false |
| positive rate, then it may make the sequence infinite, effectively |
| disabling its use as a prefilter.</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Seq, Literal}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[ |
| <span class="string">"samantha"</span>, |
| <span class="comment">// An empty string matches at every position, |
| // thus rendering the prefilter completely |
| // ineffective. |
| </span><span class="string">""</span>, |
| <span class="string">"sam"</span>, |
| <span class="string">"samwise"</span>, |
| <span class="string">"frodo"</span>, |
| ]); |
| seq.optimize_for_prefix_by_preference(); |
| <span class="macro">assert!</span>(!seq.is_finite());</code></pre></div> |
| <p>Do note that just because there is a <code>" "</code> in the sequence, that |
| doesn’t mean the sequence will always be made infinite after it is |
| optimized. Namely, if the sequence is considered exact (any match |
| corresponds to an overall match of the original regex), then any match |
| is an overall match, and so the false positive rate is always <code>0</code>.</p> |
| <p>To demonstrate this, we remove <code>samwise</code> from our sequence. This |
| results in no optimization happening and all literals remain exact. |
| Thus the entire sequence is exact, and it is kept as-is, even though |
| one is an ASCII space:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>regex_syntax::hir::literal::{Seq, Literal}; |
| |
| <span class="kw">let </span><span class="kw-2">mut </span>seq = Seq::new(<span class="kw-2">&</span>[ |
| <span class="string">"samantha"</span>, |
| <span class="string">" "</span>, |
| <span class="string">"sam"</span>, |
| <span class="string">"frodo"</span>, |
| ]); |
| seq.optimize_for_prefix_by_preference(); |
| <span class="macro">assert!</span>(seq.is_finite());</code></pre></div> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.optimize_for_suffix_by_preference" class="method has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1835-1837">source</a><h4 class="code-header">pub fn <a href="#method.optimize_for_suffix_by_preference" class="fnname">optimize_for_suffix_by_preference</a>(&mut self)</h4></section></summary><div class="docblock"><p>Optimizes this seq while treating its literals as suffixes and |
| respecting the preference order of its literals.</p> |
| <p>Optimization should only be run once extraction is complete.</p> |
| <p>The <a href="struct.Seq.html#method.optimize_for_prefix_by_preference" title="Seq::optimize_for_prefix_by_preference"><code>Seq::optimize_for_prefix_by_preference</code></a> does the same thing, but |
| for prefixes. See its documentation for more explanation.</p> |
| </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-Seq" class="impl has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#736">source</a><a href="#impl-Clone-for-Seq" 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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</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/literal.rs.html#736">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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</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-Seq" class="impl has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1974-1983">source</a><a href="#impl-Debug-for-Seq" 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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</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/literal.rs.html#1975-1982">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-FromIterator%3CLiteral%3E-for-Seq" class="impl has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1985-1993">source</a><a href="#impl-FromIterator%3CLiteral%3E-for-Seq" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.FromIterator.html" title="trait core::iter::traits::collect::FromIterator">FromIterator</a><<a class="struct" href="struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a>> for <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_iter" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#1986-1992">source</a><a href="#method.from_iter" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.FromIterator.html#tymethod.from_iter" class="fnname">from_iter</a><T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a><Item = <a class="struct" href="struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a>>>(it: T) -> <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h4></section></summary><div class='docblock'>Creates a value from an iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.FromIterator.html#tymethod.from_iter">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CSeq%3E-for-Seq" class="impl has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#736">source</a><a href="#impl-PartialEq%3CSeq%3E-for-Seq" 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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a>> for <a class="struct" href="struct.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</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/literal.rs.html#736">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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</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-Seq" class="impl has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#736">source</a><a href="#impl-Eq-for-Seq" 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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h3></section><section id="impl-StructuralEq-for-Seq" class="impl has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#736">source</a><a href="#impl-StructuralEq-for-Seq" 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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h3></section><section id="impl-StructuralPartialEq-for-Seq" class="impl has-srclink"><a class="srclink rightside" href="../../../src/regex_syntax/hir/literal.rs.html#736">source</a><a href="#impl-StructuralPartialEq-for-Seq" 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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</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-Seq" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-Seq" 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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h3></section><section id="impl-Send-for-Seq" class="impl has-srclink"><a href="#impl-Send-for-Seq" 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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h3></section><section id="impl-Sync-for-Seq" class="impl has-srclink"><a href="#impl-Sync-for-Seq" 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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h3></section><section id="impl-Unpin-for-Seq" class="impl has-srclink"><a href="#impl-Unpin-for-Seq" 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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</a></h3></section><section id="impl-UnwindSafe-for-Seq" class="impl has-srclink"><a href="#impl-UnwindSafe-for-Seq" 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.Seq.html" title="struct regex_syntax::hir::literal::Seq">Seq</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-Seq" 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-Seq" 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-Seq" 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-Seq" 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-Seq" 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-Seq" 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-Seq" 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-Seq" 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-Seq" 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-Seq" 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-Seq" 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-Seq" 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-TryFrom%3CU%3E-for-Seq" 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-Seq" 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-Seq" 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-Seq" 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> |