owoify/target/doc/regex_syntax/hir/literal/struct.Literal.html

550 lines
116 KiB
HTML
Raw Normal View History

2019-08-01 13:54:11 +00:00
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `Literal` struct in crate `regex_syntax`."><meta name="keywords" content="rust, rustlang, rust-lang, Literal"><title>regex_syntax::hir::literal::Literal - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="shortcut icon" href="../../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../../regex_syntax/index.html'><div class='logo-container'><img src='../../../rust-logo.png' alt='logo'></div></a><p class='location'>Struct Literal</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.cut">cut</a><a href="#method.empty">empty</a><a href="#method.is_cut">is_cut</a><a href="#method.new">new</a></div><a class="sidebar-title" href="#deref-methods">Methods from Deref&lt;Target=Vec&lt;u8&gt;&gt;</a><div class="sidebar-links"><a href="#method.as_slice">as_slice</a><a href="#method.capacity">capacity</a><a href="#method.is_empty">is_empty</a><a href="#method.len">len</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3C%5Bu8%5D%3E">AsRef&lt;[u8]&gt;</a><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Deref">Deref</a><a href="#impl-DerefMut">DerefMut</a><a href="#impl-Eq">Eq</a><a href="#impl-Ord">Ord</a><a href="#impl-PartialEq%3CLiteral%3E">PartialEq&lt;Literal&gt;</a><a href="#impl-PartialOrd%3CLiteral%3E">PartialOrd&lt;Literal&gt;</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a></div></div><p class='location'><a href='../../index.html'>regex_syntax</a>::<wbr><a href='../index.html'>hir</a>::<wbr><a href='index.html'>literal</a></p><script>window.sidebarCurrent = {name: 'Literal', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fq
<p>This type has <code>Deref</code> and <code>DerefMut</code> impls to <code>Vec&lt;u8&gt;</code> so that all slice
and <code>Vec</code> operations are available.</p>
</div><h2 id='methods' class='small-section-header'>Methods<a href='#methods' class='anchor'></a></h2><h3 id='impl' class='impl'><code class='in-band'>impl <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl' class='anchor'></a><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#879-899' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.new' class="method"><code id='new.v'>pub fn <a href='#method.new' class='fnname'>new</a>(bytes: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;) -&gt; <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#881-883' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns a new complete literal with the bytes given.</p>
</div><h4 id='method.empty' class="method"><code id='empty.v'>pub fn <a href='#method.empty' class='fnname'>empty</a>() -&gt; <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#886-888' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns a new complete empty literal.</p>
</div><h4 id='method.is_cut' class="method"><code id='is_cut.v'>pub fn <a href='#method.is_cut' class='fnname'>is_cut</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#891-893' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns true if this literal was &quot;cut.&quot;</p>
</div><h4 id='method.cut' class="method"><code id='cut.v'>pub fn <a href='#method.cut' class='fnname'>cut</a>(&amp;mut self)</code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#896-898' title='goto source code'>[src]</a></h4><div class='docblock'><p>Cuts this literal.</p>
</div></div><h2 id='deref-methods' class='small-section-header'>Methods from <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&lt;Target = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;&gt;<a href='#deref-methods' class='anchor'></a></h2><div class='impl-items'><h4 id='method.capacity' class="method"><code id='capacity.v'>pub fn <a href='#method.capacity' class='fnname'>capacity</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#434-436' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the number of elements the vector can hold without
reallocating.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">vec</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">with_capacity</span>(<span class="number">10</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>.<span class="ident">capacity</span>(), <span class="number">10</span>);</pre></div>
</div><h4 id='method.reserve' class="method"><code id='reserve.v'>pub fn <a href='#method.reserve' class='fnname'>reserve</a>(&amp;mut self, additional: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#456-458' title='goto source code'>[src]</a></h4><div class='docblock'><p>Reserves capacity for at least <code>additional</code> more elements to be inserted
in the given <code>Vec&lt;T&gt;</code>. The collection may reserve more space to avoid
frequent reallocations. After calling <code>reserve</code>, capacity will be
greater than or equal to <code>self.len() + additional</code>. Does nothing if
capacity is already sufficient.</p>
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
<p>Panics if the new capacity overflows <code>usize</code>.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>];
<span class="ident">vec</span>.<span class="ident">reserve</span>(<span class="number">10</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">vec</span>.<span class="ident">capacity</span>() <span class="op">&gt;=</span> <span class="number">11</span>);</pre></div>
</div><h4 id='method.reserve_exact' class="method"><code id='reserve_exact.v'>pub fn <a href='#method.reserve_exact' class='fnname'>reserve_exact</a>(&amp;mut self, additional: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#481-483' title='goto source code'>[src]</a></h4><div class='docblock'><p>Reserves the minimum capacity for exactly <code>additional</code> more elements to
be inserted in the given <code>Vec&lt;T&gt;</code>. After calling <code>reserve_exact</code>,
capacity will be greater than or equal to <code>self.len() + additional</code>.
Does nothing if the capacity is already sufficient.</p>
<p>Note that the allocator may give the collection more space than it
requests. Therefore, capacity can not be relied upon to be precisely
minimal. Prefer <code>reserve</code> if future insertions are expected.</p>
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
<p>Panics if the new capacity overflows <code>usize</code>.</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>];
<span class="ident">vec</span>.<span class="ident">reserve_exact</span>(<span class="number">10</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">vec</span>.<span class="ident">capacity</span>() <span class="op">&gt;=</span> <span class="number">11</span>);</pre></div>
</div><h4 id='method.try_reserve' class="method"><code id='try_reserve.v'>pub fn <a href='#method.try_reserve' class='fnname'>try_reserve</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;additional: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="enum" href="https://doc.rust-lang.org/nightly/alloc/collections/enum.CollectionAllocErr.html" title="enum alloc::collections::CollectionAllocErr">CollectionAllocErr</a>&gt;</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#518-520' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>try_reserve</code>)</summary><p>new API</p>
</details></div></div><div class='docblock'><p>Tries to reserve capacity for at least <code>additional</code> more elements to be inserted
in the given <code>Vec&lt;T&gt;</code>. The collection may reserve more space to avoid
frequent reallocations. After calling <code>reserve</code>, capacity will be
greater than or equal to <code>self.len() + additional</code>. Does nothing if
capacity is already sufficient.</p>
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
<p>If the capacity overflows, or the allocator reports a failure, then an error
is returned.</p>
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">try_reserve</span>)]</span>
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">collections</span>::<span class="ident">CollectionAllocErr</span>;
<span class="kw">fn</span> <span class="ident">process_data</span>(<span class="ident">data</span>: <span class="kw-2">&amp;</span>[<span class="ident">u32</span>]) <span class="op">-&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u32</span><span class="op">&gt;</span>, <span class="ident">CollectionAllocErr</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">output</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">new</span>();
<span class="comment">// Pre-reserve the memory, exiting if we can&#39;t</span>
<span class="ident">output</span>.<span class="ident">try_reserve</span>(<span class="ident">data</span>.<span class="ident">len</span>())<span class="question-mark">?</span>;
<span class="comment">// Now we know this can&#39;t OOM in the middle of our complex work</span>
<span class="ident">output</span>.<span class="ident">extend</span>(<span class="ident">data</span>.<span class="ident">iter</span>().<span class="ident">map</span>(<span class="op">|</span><span class="kw-2">&amp;</span><span class="ident">val</span><span class="op">|</span> {
<span class="ident">val</span> <span class="op">*</span> <span class="number">2</span> <span class="op">+</span> <span class="number">5</span> <span class="comment">// very complicated</span>
}));
<span class="prelude-val">Ok</span>(<span class="ident">output</span>)
}</pre></div>
</div><h4 id='method.try_reserve_exact' class="method"><code id='try_reserve_exact.v'>pub fn <a href='#method.try_reserve_exact' class='fnname'>try_reserve_exact</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;additional: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="enum" href="https://doc.rust-lang.org/nightly/alloc/collections/enum.CollectionAllocErr.html" title="enum alloc::collections::CollectionAllocErr">CollectionAllocErr</a>&gt;</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#558-560' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>try_reserve</code>)</summary><p>new API</p>
</details></div></div><div class='docblock'><p>Tries to reserves the minimum capacity for exactly <code>additional</code> more elements to
be inserted in the given <code>Vec&lt;T&gt;</code>. After calling <code>reserve_exact</code>,
capacity will be greater than or equal to <code>self.len() + additional</code>.
Does nothing if the capacity is already sufficient.</p>
<p>Note that the allocator may give the collection more space than it
requests. Therefore, capacity can not be relied upon to be precisely
minimal. Prefer <code>reserve</code> if future insertions are expected.</p>
<h1 id="errors-1" class="section-header"><a href="#errors-1">Errors</a></h1>
<p>If the capacity overflows, or the allocator reports a failure, then an error
is returned.</p>
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">try_reserve</span>)]</span>
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">collections</span>::<span class="ident">CollectionAllocErr</span>;
<span class="kw">fn</span> <span class="ident">process_data</span>(<span class="ident">data</span>: <span class="kw-2">&amp;</span>[<span class="ident">u32</span>]) <span class="op">-&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u32</span><span class="op">&gt;</span>, <span class="ident">CollectionAllocErr</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">output</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">new</span>();
<span class="comment">// Pre-reserve the memory, exiting if we can&#39;t</span>
<span class="ident">output</span>.<span class="ident">try_reserve</span>(<span class="ident">data</span>.<span class="ident">len</span>())<span class="question-mark">?</span>;
<span class="comment">// Now we know this can&#39;t OOM in the middle of our complex work</span>
<span class="ident">output</span>.<span class="ident">extend</span>(<span class="ident">data</span>.<span class="ident">iter</span>().<span class="ident">map</span>(<span class="op">|</span><span class="kw-2">&amp;</span><span class="ident">val</span><span class="op">|</span> {
<span class="ident">val</span> <span class="op">*</span> <span class="number">2</span> <span class="op">+</span> <span class="number">5</span> <span class="comment">// very complicated</span>
}));
<span class="prelude-val">Ok</span>(<span class="ident">output</span>)
}</pre></div>
</div><h4 id='method.shrink_to_fit' class="method"><code id='shrink_to_fit.v'>pub fn <a href='#method.shrink_to_fit' class='fnname'>shrink_to_fit</a>(&amp;mut self)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#577-581' title='goto source code'>[src]</a></h4><div class='docblock'><p>Shrinks the capacity of the vector as much as possible.</p>
<p>It will drop down as close as possible to the length but the allocator
may still inform the vector that there is space for a few more elements.</p>
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">with_capacity</span>(<span class="number">10</span>);
<span class="ident">vec</span>.<span class="ident">extend</span>([<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>.<span class="ident">capacity</span>(), <span class="number">10</span>);
<span class="ident">vec</span>.<span class="ident">shrink_to_fit</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">vec</span>.<span class="ident">capacity</span>() <span class="op">&gt;=</span> <span class="number">3</span>);</pre></div>
</div><h4 id='method.shrink_to' class="method"><code id='shrink_to.v'>pub fn <a href='#method.shrink_to' class='fnname'>shrink_to</a>(&amp;mut self, min_capacity: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#604-606' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>shrink_to</code>)</summary><p>new API</p>
</details></div></div><div class='docblock'><p>Shrinks the capacity of the vector with a lower bound.</p>
<p>The capacity will remain at least as large as both the length
and the supplied value.</p>
<p>Panics if the current capacity is smaller than the supplied
minimum capacity.</p>
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">shrink_to</span>)]</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">with_capacity</span>(<span class="number">10</span>);
<span class="ident">vec</span>.<span class="ident">extend</span>([<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>.<span class="ident">capacity</span>(), <span class="number">10</span>);
<span class="ident">vec</span>.<span class="ident">shrink_to</span>(<span class="number">4</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">vec</span>.<span class="ident">capacity</span>() <span class="op">&gt;=</span> <span class="number">4</span>);
<span class="ident">vec</span>.<span class="ident">shrink_to</span>(<span class="number">0</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">vec</span>.<span class="ident">capacity</span>() <span class="op">&gt;=</span> <span class="number">3</span>);</pre></div>
</div><h4 id='method.truncate' class="method"><code id='truncate.v'>pub fn <a href='#method.truncate' class='fnname'>truncate</a>(&amp;mut self, len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#685-702' title='goto source code'>[src]</a></h4><div class='docblock'><p>Shortens the vector, keeping the first <code>len</code> elements and dropping
the rest.</p>
<p>If <code>len</code> is greater than the vector's current length, this has no
effect.</p>
<p>The <a href="#method.drain"><code>drain</code></a> method can emulate <code>truncate</code>, but causes the excess
elements to be returned instead of dropped.</p>
<p>Note that this method has no effect on the allocated capacity
of the vector.</p>
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
<p>Truncating a five element vector to two elements:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>];
<span class="ident">vec</span>.<span class="ident">truncate</span>(<span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">2</span>]);</pre></div>
<p>No truncation occurs when <code>len</code> is greater than the vector's current
length:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="ident">vec</span>.<span class="ident">truncate</span>(<span class="number">8</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]);</pre></div>
<p>Truncating when <code>len == 0</code> is equivalent to calling the <a href="#method.clear"><code>clear</code></a>
method.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="ident">vec</span>.<span class="ident">truncate</span>(<span class="number">0</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, []);</pre></div>
</div><h4 id='method.as_slice' class="method"><code id='as_slice.v'>pub fn <a href='#method.as_slice' class='fnname'>as_slice</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[T]</a></code><span class='since' title='Stable since Rust version 1.7.0'>1.7.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#717-719' title='goto source code'>[src]</a></h4><div class='docblock'><p>Extracts a slice containing the entire vector.</p>
<p>Equivalent to <code>&amp;s[..]</code>.</p>
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::{<span class="self">self</span>, <span class="ident">Write</span>};
<span class="kw">let</span> <span class="ident">buffer</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">8</span>];
<span class="ident">io</span>::<span class="ident">sink</span>().<span class="ident">write</span>(<span class="ident">buffer</span>.<span class="ident">as_slice</span>()).<span class="ident">unwrap</span>();</pre></div>
</div><h4 id='method.as_mut_slice' class="method"><code id='as_mut_slice.v'>pub fn <a href='#method.as_mut_slice' class='fnname'>as_mut_slice</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [T]</a></code><span class='since' title='Stable since Rust version 1.7.0'>1.7.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#734-736' title='goto source code'>[src]</a></h4><div class='docblock'><p>Extracts a mutable slice of the entire vector.</p>
<p>Equivalent to <code>&amp;mut s[..]</code>.</p>
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::{<span class="self">self</span>, <span class="ident">Read</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buffer</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>; <span class="number">3</span>];
<span class="ident">io</span>::<span class="ident">repeat</span>(<span class="number">0b101</span>).<span class="ident">read_exact</span>(<span class="ident">buffer</span>.<span class="ident">as_mut_slice</span>()).<span class="ident">unwrap</span>();</pre></div>
</div><h4 id='method.set_len' class="method"><code id='set_len.v'>pub unsafe fn <a href='#method.set_len' class='fnname'>set_len</a>(&amp;mut self, new_len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#818-822' title='goto source code'>[src]</a></h4><div class='docblock'><p>Forces the length of the vector to <code>new_len</code>.</p>
<p>This is a low-level operation that maintains none of the normal
invariants of the type. Normally changing the length of a vector
is done using one of the safe operations instead, such as
<a href="#method.truncate"><code>truncate</code></a>, <a href="#method.resize"><code>resize</code></a>, <a href="#method.extend-1"><code>extend</code></a>, or <a href="#method.clear"><code>clear</code></a>.</p>
<h1 id="safety" class="section-header"><a href="#safety">Safety</a></h1>
<ul>
<li><code>new_len</code> must be less than or equal to <a href="#method.capacity"><code>capacity()</code></a>.</li>
<li>The elements at <code>old_len..new_len</code> must be initialized.</li>
</ul>
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
<p>This method can be useful for situations in which the vector
is serving as a buffer for other code, particularly over FFI:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">get_dictionary</span>(<span class="kw-2">&amp;</span><span class="self">self</span>) <span class="op">-&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u8</span><span class="op">&gt;&gt;</span> {
<span class="comment">// Per the FFI method&#39;s docs, &quot;32768 bytes is always enough&quot;.</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dict</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">with_capacity</span>(<span class="number">32_768</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dict_length</span> <span class="op">=</span> <span class="number">0</span>;
<span class="comment">// SAFETY: When `deflateGetDictionary` returns `Z_OK`, it holds that:</span>
<span class="comment">// 1. `dict_length` elements were initialized.</span>
<span class="comment">// 2. `dict_length` &lt;= the capacity (32_768)</span>
<span class="comment">// which makes `set_len` safe to call.</span>
<span class="kw">unsafe</span> {
<span class="comment">// Make the FFI call...</span>
<span class="kw">let</span> <span class="ident">r</span> <span class="op">=</span> <span class="ident">deflateGetDictionary</span>(<span class="self">self</span>.<span class="ident">strm</span>, <span class="ident">dict</span>.<span class="ident">as_mut_ptr</span>(), <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">dict_length</span>);
<span class="kw">if</span> <span class="ident">r</span> <span class="op">==</span> <span class="ident">Z_OK</span> {
<span class="comment">// ...and update the length to what was initialized.</span>
<span class="ident">dict</span>.<span class="ident">set_len</span>(<span class="ident">dict_length</span>);
<span class="prelude-val">Some</span>(<span class="ident">dict</span>)
} <span class="kw">else</span> {
<span class="prelude-val">None</span>
}
}
}</pre></div>
<p>While the following example is sound, there is a memory leak since
the inner vectors were not freed prior to the <code>set_len</code> call:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">0</span>, <span class="number">0</span>],
<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">0</span>],
<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>]];
<span class="comment">// SAFETY:</span>
<span class="comment">// 1. `old_len..0` is empty so no elements need to be initialized.</span>
<span class="comment">// 2. `0 &lt;= capacity` always holds whatever `capacity` is.</span>
<span class="kw">unsafe</span> {
<span class="ident">vec</span>.<span class="ident">set_len</span>(<span class="number">0</span>);
}</pre></div>
<p>Normally, here, one would use <a href="#method.clear"><code>clear</code></a> instead to correctly drop
the contents and thus not leak memory.</p>
</div><h4 id='method.swap_remove' class="method"><code id='swap_remove.v'>pub fn <a href='#method.swap_remove' class='fnname'>swap_remove</a>(&amp;mut self, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; T</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#847-857' title='goto source code'>[src]</a></h4><div class='docblock'><p>Removes an element from the vector and returns it.</p>
<p>The removed element is replaced by the last element of the vector.</p>
<p>This does not preserve ordering, but is O(1).</p>
<h1 id="panics-2" class="section-header"><a href="#panics-2">Panics</a></h1>
<p>Panics if <code>index</code> is out of bounds.</p>
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;foo&quot;</span>, <span class="string">&quot;bar&quot;</span>, <span class="string">&quot;baz&quot;</span>, <span class="string">&quot;qux&quot;</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">swap_remove</span>(<span class="number">1</span>), <span class="string">&quot;bar&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, [<span class="string">&quot;foo&quot;</span>, <span class="string">&quot;qux&quot;</span>, <span class="string">&quot;baz&quot;</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">swap_remove</span>(<span class="number">0</span>), <span class="string">&quot;foo&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, [<span class="string">&quot;baz&quot;</span>, <span class="string">&quot;qux&quot;</span>]);</pre></div>
</div><h4 id='method.insert' class="method"><code id='insert.v'>pub fn <a href='#method.insert' class='fnname'>insert</a>(&amp;mut self, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, element: T)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#876-899' title='goto source code'>[src]</a></h4><div class='docblock'><p>Inserts an element at position <code>index</code> within the vector, shifting all
elements after it to the right.</p>
<h1 id="panics-3" class="section-header"><a href="#panics-3">Panics</a></h1>
<p>Panics if <code>index &gt; len</code>.</p>
<h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="ident">vec</span>.<span class="ident">insert</span>(<span class="number">1</span>, <span class="number">4</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">4</span>, <span class="number">2</span>, <span class="number">3</span>]);
<span class="ident">vec</span>.<span class="ident">insert</span>(<span class="number">4</span>, <span class="number">5</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">4</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">5</span>]);</pre></div>
</div><h4 id='method.remove' class="method"><code id='remove.v'>pub fn <a href='#method.remove' class='fnname'>remove</a>(&amp;mut self, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; T</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#916-935' title='goto source code'>[src]</a></h4><div class='docblock'><p>Removes and returns the element at position <code>index</code> within the vector,
shifting all elements after it to the left.</p>
<h1 id="panics-4" class="section-header"><a href="#panics-4">Panics</a></h1>
<p>Panics if <code>index</code> is out of bounds.</p>
<h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">remove</span>(<span class="number">1</span>), <span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, [<span class="number">1</span>, <span class="number">3</span>]);</pre></div>
</div><h4 id='method.retain' class="method"><code id='retain.v'>pub fn <a href='#method.retain' class='fnname'>retain</a>&lt;F&gt;(&amp;mut self, f: F) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#961-965' title='goto source code'>[src]</a></h4><div class='docblock'><p>Retains only the elements specified by the predicate.</p>
<p>In other words, remove all elements <code>e</code> such that <code>f(&amp;e)</code> returns <code>false</code>.
This method operates in place, visiting each element exactly once in the
original order, and preserves the order of the retained elements.</p>
<h1 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>];
<span class="ident">vec</span>.<span class="ident">retain</span>(<span class="op">|</span><span class="kw-2">&amp;</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span><span class="op">%</span><span class="number">2</span> <span class="op">==</span> <span class="number">0</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">2</span>, <span class="number">4</span>]);</pre></div>
<p>The exact order may be useful for tracking external state, like an index.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>];
<span class="kw">let</span> <span class="ident">keep</span> <span class="op">=</span> [<span class="bool-val">false</span>, <span class="bool-val">true</span>, <span class="bool-val">true</span>, <span class="bool-val">false</span>, <span class="bool-val">true</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">i</span> <span class="op">=</span> <span class="number">0</span>;
<span class="ident">vec</span>.<span class="ident">retain</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> (<span class="ident">keep</span>[<span class="ident">i</span>], <span class="ident">i</span> <span class="op">+=</span> <span class="number">1</span>).<span class="number">0</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">2</span>, <span class="number">3</span>, <span class="number">5</span>]);</pre></div>
</div><h4 id='method.dedup_by_key' class="method"><code id='dedup_by_key.v'>pub fn <a href='#method.dedup_by_key' class='fnname'>dedup_by_key</a>&lt;F, K&gt;(&amp;mut self, key: F) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T) -&gt; K,<br>&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&lt;K&gt;,&nbsp;</span></code><span class='since' title='Stable since Rust version 1.16.0'>1.16.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#983-985' title='goto source code'>[src]</a></h4><div class='docblock'><p>Removes all but the first of consecutive elements in the vector that resolve to the same
key.</p>
<p>If the vector is sorted, this removes all duplicates.</p>
<h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">10</span>, <span class="number">20</span>, <span class="number">21</span>, <span class="number">30</span>, <span class="number">20</span>];
<span class="ident">vec</span>.<span class="ident">dedup_by_key</span>(<span class="op">|</span><span class="ident">i</span><span class="op">|</span> <span class="kw-2">*</span><span class="ident">i</span> <span class="op">/</span> <span class="number">10</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">10</span>, <span class="number">20</span>, <span class="number">30</span>, <span class="number">20</span>]);</pre></div>
</div><h4 id='method.dedup_by' class="method"><code id='dedup_by.v'>pub fn <a href='#method.dedup_by' class='fnname'>dedup_by</a>&lt;F&gt;(&amp;mut self, same_bucket: F) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></code><span class='since' title='Stable since Rust version 1.16.0'>1.16.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1006-1012' title='goto source code'>[src]</a></h4><div class='docblock'><p>Removes all but the first of consecutive elements in the vector satisfying a given equality
relation.</p>
<p>The <code>same_bucket</code> function is passed references to two elements from the vector and
must determine if the elements compare equal. The elements are passed in opposite order
from their order in the slice, so if <code>same_bucket(a, b)</code> returns <code>true</code>, <code>a</code> is removed.</p>
<p>If the vector is sorted, this removes all duplicates.</p>
<h1 id="examples-16" class="section-header"><a href="#examples-16">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;foo&quot;</span>, <span class="string">&quot;bar&quot;</span>, <span class="string">&quot;Bar&quot;</span>, <span class="string">&quot;baz&quot;</span>, <span class="string">&quot;bar&quot;</span>];
<span class="ident">vec</span>.<span class="ident">dedup_by</span>(<span class="op">|</span><span class="ident">a</span>, <span class="ident">b</span><span class="op">|</span> <span class="ident">a</span>.<span class="ident">eq_ignore_ascii_case</span>(<span class="ident">b</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="string">&quot;foo&quot;</span>, <span class="string">&quot;bar&quot;</span>, <span class="string">&quot;baz&quot;</span>, <span class="string">&quot;bar&quot;</span>]);</pre></div>
</div><h4 id='method.push' class="method"><code id='push.v'>pub fn <a href='#method.push' class='fnname'>push</a>(&amp;mut self, value: T)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1029-1040' title='goto source code'>[src]</a></h4><div class='docblock'><p>Appends an element to the back of a collection.</p>
<h1 id="panics-5" class="section-header"><a href="#panics-5">Panics</a></h1>
<p>Panics if the number of elements in the vector overflows a <code>usize</code>.</p>
<h1 id="examples-17" class="section-header"><a href="#examples-17">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>];
<span class="ident">vec</span>.<span class="ident">push</span>(<span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]);</pre></div>
</div><h4 id='method.pop' class="method"><code id='pop.v'>pub fn <a href='#method.pop' class='fnname'>pop</a>(&amp;mut self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;T&gt;</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1056-1065' title='goto source code'>[src]</a></h4><div class='docblock'><p>Removes the last element from a vector and returns it, or <a href="../../std/option/enum.Option.html#variant.None"><code>None</code></a> if it
is empty.</p>
<h1 id="examples-18" class="section-header"><a href="#examples-18">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>.<span class="ident">pop</span>(), <span class="prelude-val">Some</span>(<span class="number">3</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">2</span>]);</pre></div>
</div><h4 id='method.append' class="method"><code id='append.v'>pub fn <a href='#method.append' class='fnname'>append</a>(&amp;mut self, other: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;T&gt;)</code><span class='since' title='Stable since Rust version 1.4.0'>1.4.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1084-1089' title='goto source code'>[src]</a></h4><div class='docblock'><p>Moves all the elements of <code>other</code> into <code>Self</code>, leaving <code>other</code> empty.</p>
<h1 id="panics-6" class="section-header"><a href="#panics-6">Panics</a></h1>
<p>Panics if the number of elements in the vector overflows a <code>usize</code>.</p>
<h1 id="examples-19" class="section-header"><a href="#examples-19">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec2</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>];
<span class="ident">vec</span>.<span class="ident">append</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">vec2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec2</span>, []);</pre></div>
</div><h4 id='method.drain' class="method"><code id='drain.v'>pub fn <a href='#method.drain' class='fnname'>drain</a>&lt;R&gt;(&amp;mut self, range: R) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Drain.html" title="struct alloc::vec::Drain">Drain</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/range/trait.RangeBounds.html" title="trait core::ops::range::RangeBounds">RangeBounds</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;,&nbsp;</span></code><span class='since' title='Stable since Rust version 1.6.0'>1.6.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1128-1169' title='goto source code'>[src]</a></h4><div class='docblock'><p>Creates a draining iterator that removes the specified range in the vector
and yields the removed items.</p>
<p>Note 1: The element range is removed even if the iterator is only
partially consumed or not consumed at all.</p>
<p>Note 2: It is unspecified how many elements are removed from the vector
if the <code>Drain</code> value is leaked.</p>
<h1 id="panics-7" class="section-header"><a href="#panics-7">Panics</a></h1>
<p>Panics if the starting point is greater than the end point or if
the end point is greater than the length of the vector.</p>
<h1 id="examples-20" class="section-header"><a href="#examples-20">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="kw">let</span> <span class="ident">u</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">v</span>.<span class="ident">drain</span>(<span class="number">1</span>..).<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, <span class="kw-2">&amp;</span>[<span class="number">1</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">u</span>, <span class="kw-2">&amp;</span>[<span class="number">2</span>, <span class="number">3</span>]);
<span class="comment">// A full range clears the vector</span>
<span class="ident">v</span>.<span class="ident">drain</span>(..);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, <span class="kw-2">&amp;</span>[]);</pre></div>
</div><h4 id='method.clear' class="method"><code id='clear.v'>pub fn <a href='#method.clear' class='fnname'>clear</a>(&amp;mut self)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1187-1189' title='goto source code'>[src]</a></h4><div class='docblock'><p>Clears the vector, removing all values.</p>
<p>Note that this method has no effect on the allocated capacity
of the vector.</p>
<h1 id="examples-21" class="section-header"><a href="#examples-21">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="ident">v</span>.<span class="ident">clear</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">is_empty</span>());</pre></div>
</div><h4 id='method.len' class="method"><code id='len.v'>pub fn <a href='#method.len' class='fnname'>len</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1202-1204' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns the number of elements in the vector, also referred to
as its 'length'.</p>
<h1 id="examples-22" class="section-header"><a href="#examples-22">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">len</span>(), <span class="number">3</span>);</pre></div>
</div><h4 id='method.is_empty' class="method"><code id='is_empty.v'>pub fn <a href='#method.is_empty' class='fnname'>is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1218-1220' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns <code>true</code> if the vector contains no elements.</p>
<h1 id="examples-23" class="section-header"><a href="#examples-23">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">new</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">is_empty</span>());
<span class="ident">v</span>.<span class="ident">push</span>(<span class="number">1</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">v</span>.<span class="ident">is_empty</span>());</pre></div>
</div><h4 id='method.split_off' class="method"><code id='split_off.v'>pub fn <a href='#method.split_off' class='fnname'>split_off</a>(&amp;mut self, at: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;T&gt;</code><span class='since' title='Stable since Rust version 1.4.0'>1.4.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1243-1259' title='goto source code'>[src]</a></h4><div class='docblock'><p>Splits the collection into two at the given index.</p>
<p>Returns a newly allocated <code>Self</code>. <code>self</code> contains elements <code>[0, at)</code>,
and the returned <code>Self</code> contains elements <code>[at, len)</code>.</p>
<p>Note that the capacity of <code>self</code> does not change.</p>
<h1 id="panics-8" class="section-header"><a href="#panics-8">Panics</a></h1>
<p>Panics if <code>at &gt; len</code>.</p>
<h1 id="examples-24" class="section-header"><a href="#examples-24">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>];
<span class="kw">let</span> <span class="ident">vec2</span> <span class="op">=</span> <span class="ident">vec</span>.<span class="ident">split_off</span>(<span class="number">1</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec2</span>, [<span class="number">2</span>, <span class="number">3</span>]);</pre></div>
</div><h4 id='method.resize_with' class="method"><code id='resize_with.v'>pub fn <a href='#method.resize_with' class='fnname'>resize_with</a>&lt;F&gt;(&amp;mut self, new_len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, f: F) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>() -&gt; T,&nbsp;</span></code><span class='since' title='Stable since Rust version 1.33.0'>1.33.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1291-1300' title='goto source code'>[src]</a></h4><div class='docblock'><p>Resizes the <code>Vec</code> in-place so that <code>len</code> is equal to <code>new_len</code>.</p>
<p>If <code>new_len</code> is greater than <code>len</code>, the <code>Vec</code> is extended by the
difference, with each additional slot filled with the result of
calling the closure <code>f</code>. The return values from <code>f</code> will end up
in the <code>Vec</code> in the order they have been generated.</p>
<p>If <code>new_len</code> is less than <code>len</code>, the <code>Vec</code> is simply truncated.</p>
<p>This method uses a closure to create new values on every push. If
you'd rather <a href="../../std/clone/trait.Clone.html"><code>Clone</code></a> a given value, use <a href="#method.resize"><code>resize</code></a>. If you want
to use the [<code>Default</code>] trait to generate values, you can pass
[<code>Default::default()</code>] as the second argument.</p>
<h1 id="examples-25" class="section-header"><a href="#examples-25">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="ident">vec</span>.<span class="ident">resize_with</span>(<span class="number">5</span>, <span class="ident">Default</span>::<span class="ident">default</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>]);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">p</span> <span class="op">=</span> <span class="number">1</span>;
<span class="ident">vec</span>.<span class="ident">resize_with</span>(<span class="number">4</span>, <span class="op">||</span> { <span class="ident">p</span> <span class="op">*=</span> <span class="number">2</span>; <span class="ident">p</span> });
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">2</span>, <span class="number">4</span>, <span class="number">8</span>, <span class="number">16</span>]);</pre></div>
</div></div><div class='impl-items'><h4 id='method.resize' class="method"><code id='resize.v'>pub fn <a href='#method.resize' class='fnname'>resize</a>(&amp;mut self, new_len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, value: T)</code><span class='since' title='Stable since Rust version 1.5.0'>1.5.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1330-1338' title='goto source code'>[src]</a></h4><div class='docblock'><p>Resizes the <code>Vec</code> in-place so that <code>len</code> is equal to <code>new_len</code>.</p>
<p>If <code>new_len</code> is greater than <code>len</code>, the <code>Vec</code> is extended by the
difference, with each additional slot filled with <code>value</code>.
If <code>new_len</code> is less than <code>len</code>, the <code>Vec</code> is simply truncated.</p>
<p>This method requires <a href="../../std/clone/trait.Clone.html"><code>Clone</code></a> to be able clone the passed value. If
you need more flexibility (or want to rely on <a href="../../std/default/trait.Default.html"><code>Default</code></a> instead of
<a href="../../std/clone/trait.Clone.html"><code>Clone</code></a>), use <a href="#method.resize_with"><code>resize_with</code></a>.</p>
<h1 id="examples-26" class="section-header"><a href="#examples-26">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;hello&quot;</span>];
<span class="ident">vec</span>.<span class="ident">resize</span>(<span class="number">3</span>, <span class="string">&quot;world&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="string">&quot;hello&quot;</span>, <span class="string">&quot;world&quot;</span>, <span class="string">&quot;world&quot;</span>]);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>];
<span class="ident">vec</span>.<span class="ident">resize</span>(<span class="number">2</span>, <span class="number">0</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">2</span>]);</pre></div>
</div><h4 id='method.extend_from_slice' class="method"><code id='extend_from_slice.v'>pub fn <a href='#method.extend_from_slice' class='fnname'>extend_from_slice</a>(&amp;mut self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[T]</a>)</code><span class='since' title='Stable since Rust version 1.6.0'>1.6.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1360-1362' title='goto source code'>[src]</a></h4><div class='docblock'><p>Clones and appends all elements in a slice to the <code>Vec</code>.</p>
<p>Iterates over the slice <code>other</code>, clones each element, and then appends
it to this <code>Vec</code>. The <code>other</code> vector is traversed in-order.</p>
<p>Note that this function is same as <a href="#method.extend"><code>extend</code></a> except that it is
specialized to work with slices instead. If and when Rust gets
specialization this function will likely be deprecated (but still
available).</p>
<h1 id="examples-27" class="section-header"><a href="#examples-27">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>];
<span class="ident">vec</span>.<span class="ident">extend_from_slice</span>(<span class="kw-2">&amp;</span>[<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);</pre></div>
</div></div><div class='impl-items'><h4 id='method.resize_default' class="method"><code id='resize_default.v'>pub fn <a href='#method.resize_default' class='fnname'>resize_default</a>(&amp;mut self, new_len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1398-1406' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab deprecated'>Deprecated since 1.33.0: <p>This is moving towards being removed in favor of <code>.resize_with(Default::default)</code>. If you disagree, please comment in the tracking issue.</p>
</div><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>vec_resize_default</code>)</div></div><div class='docblock'><p>Resizes the <code>Vec</code> in-place so that <code>len</code> is equal to <code>new_len</code>.</p>
<p>If <code>new_len</code> is greater than <code>len</code>, the <code>Vec</code> is extended by the
difference, with each additional slot filled with <a href="../../std/default/trait.Default.html#tymethod.default"><code>Default::default()</code></a>.
If <code>new_len</code> is less than <code>len</code>, the <code>Vec</code> is simply truncated.</p>
<p>This method uses <a href="../../std/default/trait.Default.html"><code>Default</code></a> to create new values on every push. If
you'd rather <a href="../../std/clone/trait.Clone.html"><code>Clone</code></a> a given value, use <a href="#method.resize"><code>resize</code></a>.</p>
<h1 id="examples-28" class="section-header"><a href="#examples-28">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">vec_resize_default</span>)]</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="ident">vec</span>.<span class="ident">resize_default</span>(<span class="number">5</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>]);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>];
<span class="ident">vec</span>.<span class="ident">resize_default</span>(<span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">2</span>]);</pre></div>
</div></div><div class='impl-items'><h4 id='method.dedup' class="method"><code id='dedup.v'>pub fn <a href='#method.dedup' class='fnname'>dedup</a>(&amp;mut self)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1515-1517' title='goto source code'>[src]</a></h4><div class='docblock'><p>Removes consecutive repeated elements in the vector according to the
[<code>PartialEq</code>] trait implementation.</p>
<p>If the vector is sorted, this removes all duplicates.</p>
<h1 id="examples-29" class="section-header"><a href="#examples-29">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">2</span>];
<span class="ident">vec</span>.<span class="ident">dedup</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">2</span>]);</pre></div>
</div><h4 id='method.remove_item' class="method"><code id='remove_item.v'>pub fn <a href='#method.remove_item' class='fnname'>remove_item</a>(&amp;mut self, item: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;T&gt;</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1532-1535' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>vec_remove_item</code>)</summary><p>recently added</p>
</details></div></div><div class='docblock'><p>Removes the first instance of <code>item</code> from the vector if the item exists.</p>
<h1 id="examples-30" class="section-header"><a href="#examples-30">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">1</span>];
<span class="ident">vec</span>.<span class="ident">remove_item</span>(<span class="kw-2">&amp;</span><span class="number">1</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="number">2</span>, <span class="number">3</span>, <span class="number">1</span>]);</pre></div>
</div></div><div class='impl-items'><h4 id='method.splice' class="method"><code id='splice.v'>pub fn <a href='#method.splice' class='fnname'>splice</a>&lt;R, I&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;range: R, <br>&nbsp;&nbsp;&nbsp;&nbsp;replace_with: I<br>) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Splice.html" title="struct alloc::vec::Splice">Splice</a>&lt;&lt;I as <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>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::collect::IntoIterator::IntoIter">IntoIter</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;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>&lt;Item = T&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/range/trait.RangeBounds.html" title="trait core::ops::range::RangeBounds">RangeBounds</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;,&nbsp;</span></code><span class='since' title='Stable since Rust version 1.21.0'>1.21.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#1990-1997' title='goto source code'>[src]</a></h4><div class='docblock'><p>Creates a splicing iterator that replaces the specified range in the vector
with the given <code>replace_with</code> iterator and yields the removed items.
<code>replace_with</code> does not need to be the same length as <code>range</code>.</p>
<p>Note 1: The element range is removed even if the iterator is not
consumed until the end.</p>
<p>Note 2: It is unspecified how many elements are removed from the vector,
if the <code>Splice</code> value is leaked.</p>
<p>Note 3: The input iterator <code>replace_with</code> is only consumed
when the <code>Splice</code> value is dropped.</p>
<p>Note 4: This is optimal if:</p>
<ul>
<li>The tail (elements in the vector after <code>range</code>) is empty,</li>
<li>or <code>replace_with</code> yields fewer elements than <code>range</code>s length</li>
<li>or the lower bound of its <code>size_hint()</code> is exact.</li>
</ul>
<p>Otherwise, a temporary vector is allocated and the tail is moved twice.</p>
<h1 id="panics-9" class="section-header"><a href="#panics-9">Panics</a></h1>
<p>Panics if the starting point is greater than the end point or if
the end point is greater than the length of the vector.</p>
<h1 id="examples-31" class="section-header"><a href="#examples-31">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="kw">let</span> <span class="ident">new</span> <span class="op">=</span> [<span class="number">7</span>, <span class="number">8</span>];
<span class="kw">let</span> <span class="ident">u</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">v</span>.<span class="ident">splice</span>(..<span class="number">2</span>, <span class="ident">new</span>.<span class="ident">iter</span>().<span class="ident">cloned</span>()).<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, <span class="kw-2">&amp;</span>[<span class="number">7</span>, <span class="number">8</span>, <span class="number">3</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">u</span>, <span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">2</span>]);</pre></div>
</div><h4 id='method.drain_filter' class="method"><code id='drain_filter.v'>pub fn <a href='#method.drain_filter' class='fnname'>drain_filter</a>&lt;F&gt;(&amp;mut self, filter: F) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.DrainFilter.html" title="struct alloc::vec::DrainFilter">DrainFilter</a>&lt;T, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/vec.rs.html#2045-2060' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>drain_filter</code>)</summary><p>recently added</p>
</details></div></div><div class='docblock'><p>Creates an iterator which uses a closure to determine if an element should be removed.</p>
<p>If the closure returns true, then the element is removed and yielded.
If the closure returns false, the element will remain in the vector and will not be yielded
by the iterator.</p>
<p>Using this method is equivalent to the following code:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">i</span> <span class="op">=</span> <span class="number">0</span>;
<span class="kw">while</span> <span class="ident">i</span> <span class="op">!=</span> <span class="ident">vec</span>.<span class="ident">len</span>() {
<span class="kw">if</span> <span class="ident">some_predicate</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">vec</span>[<span class="ident">i</span>]) {
<span class="kw">let</span> <span class="ident">val</span> <span class="op">=</span> <span class="ident">vec</span>.<span class="ident">remove</span>(<span class="ident">i</span>);
<span class="comment">// your code here</span>
} <span class="kw">else</span> {
<span class="ident">i</span> <span class="op">+=</span> <span class="number">1</span>;
}
}
</pre></div>
<p>But <code>drain_filter</code> is easier to use. <code>drain_filter</code> is also more efficient,
because it can backshift the elements of the array in bulk.</p>
<p>Note that <code>drain_filter</code> also lets you mutate every element in the filter closure,
regardless of whether you choose to keep or remove it.</p>
<h1 id="examples-32" class="section-header"><a href="#examples-32">Examples</a></h1>
<p>Splitting an array into evens and odds, reusing the original allocation:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">drain_filter</span>)]</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">8</span>, <span class="number">9</span>, <span class="number">11</span>, <span class="number">13</span>, <span class="number">14</span>, <span class="number">15</span>];
<span class="kw">let</span> <span class="ident">evens</span> <span class="op">=</span> <span class="ident">numbers</span>.<span class="ident">drain_filter</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="kw-2">*</span><span class="ident">x</span> <span class="op">%</span> <span class="number">2</span> <span class="op">==</span> <span class="number">0</span>).<span class="ident">collect</span>::<span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;&gt;</span>();
<span class="kw">let</span> <span class="ident">odds</span> <span class="op">=</span> <span class="ident">numbers</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">evens</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="number">2</span>, <span class="number">4</span>, <span class="number">6</span>, <span class="number">8</span>, <span class="number">14</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">odds</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">9</span>, <span class="number">11</span>, <span class="number">13</span>, <span class="number">15</span>]);</pre></div>
</div></div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-PartialEq%3CLiteral%3E' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&lt;<a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a>&gt; for <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl-PartialEq%3CLiteral%3E' class='anchor'></a><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#901-905' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.eq' class="method hidden"><code id='eq.v'>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, other: &amp;<a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#902-904' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>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></p>
</div><h4 id='method.ne' class="method"><code id='ne.v'><div class="docblock attributes">#[must_use]
</div>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#200' title='goto source code'>[src]</a></h4><div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 id='impl-AsRef%3C%5Bu8%5D%3E' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>&gt; for <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl-AsRef%3C%5Bu8%5D%3E' class='anchor'></a><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#923-925' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.as_ref' class="method hidden"><code id='as_ref.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref' class='fnname'>as_ref</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#924' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-Clone' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl-Clone' class='anchor'></a><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#55' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.clone' class="method hidden"><code id='clone.v'>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#55' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class="method"><code id='clone_from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self)</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/clone.rs.html#131-133' title='goto source code'>[src]</a></h4><div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 id='impl-Ord' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> for <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl-Ord' class='anchor'></a><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#55' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.cmp' class="method hidden"><code id='cmp.v'>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp' class='fnname'>cmp</a>(&amp;self, other: &amp;<a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a></code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#55' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>This method returns an <code>Ordering</code> between <code>self</code> and <code>other</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp">Read more</a></p>
</div><h4 id='method.max' class="method"><code id='max.v'>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.max' class='fnname'>max</a>(self, other: Self) -&gt; Self</code><span class='since' title='Stable since Rust version 1.21.0'>1.21.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#549-552' title='goto source code'>[src]</a></h4><div class='docblock'><p>Compares and returns the maximum of two values. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.max">Read more</a></p>
</div><h4 id='method.min' class="method"><code id='min.v'>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.min' class='fnname'>min</a>(self, other: Self) -&gt; Self</code><span class='since' title='Stable since Rust version 1.21.0'>1.21.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#566-569' title='goto source code'>[src]</a></h4><div class='docblock'><p>Compares and returns the minimum of two values. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.min">Read more</a></p>
</div><h4 id='method.clamp' class="method"><code id='clamp.v'>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.clamp' class='fnname'>clamp</a>(self, min: Self, max: Self) -&gt; Self</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#590-600' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>clamp</code>)</div></div><div class='docblock'><p>Restrict a value to a certain interval. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.clamp">Read more</a></p>
</div></div><h3 id='impl-Eq' class='impl'><code class='in-band'>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="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl-Eq' class='anchor'></a><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#55' title='goto source code'>[src]</a></h3><div class='impl-items'></div><h3 id='impl-PartialOrd%3CLiteral%3E' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>&lt;<a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a>&gt; for <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl-PartialOrd%3CLiteral%3E' class='anchor'></a><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#907-911' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.partial_cmp' class="method hidden"><code id='partial_cmp.v'>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp' class='fnname'>partial_cmp</a>(&amp;self, other: &amp;<a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>&gt;</code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#908-910' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></p>
</div><h4 id='method.lt' class="method"><code id='lt.v'><div class="docblock attributes">#[must_use]
</div>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt' class='fnname'>lt</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#772-777' title='goto source code'>[src]</a></h4><div class='docblock'><p>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code>&lt;</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt">Read more</a></p>
</div><h4 id='method.le' class="method"><code id='le.v'><div class="docblock attributes">#[must_use]
</div>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le' class='fnname'>le</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#794-799' title='goto source code'>[src]</a></h4><div class='docblock'><p>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>&lt;=</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le">Read more</a></p>
</div><h4 id='method.gt' class="method"><code id='gt.v'><div class="docblock attributes">#[must_use]
</div>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt' class='fnname'>gt</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#815-820' title='goto source code'>[src]</a></h4><div class='docblock'><p>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>&gt;</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt">Read more</a></p>
</div><h4 id='method.ge' class="method"><code id='ge.v'><div class="docblock attributes">#[must_use]
</div>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge' class='fnname'>ge</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#837-842' title='goto source code'>[src]</a></h4><div class='docblock'><p>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>&gt;=</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></p>
</div></div><h3 id='impl-Deref' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> for <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl-Deref' class='anchor'></a><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#927-930' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Target' class="type"><code id='Target.t'>type <a href='https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#associatedtype.Target' class="type">Target</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</code></h4><div class='docblock'><p>The resulting type after dereferencing.</p>
</div><h4 id='method.deref' class="method hidden"><code id='deref.v'>fn <a href='https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#tymethod.deref' class='fnname'>deref</a>(&amp;self) -&gt; &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#929' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Dereferences the value.</p>
</div></div><h3 id='impl-DerefMut' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.DerefMut.html" title="trait core::ops::deref::DerefMut">DerefMut</a> for <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl-DerefMut' class='anchor'></a><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#932-934' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.deref_mut' class="method hidden"><code id='deref_mut.v'>fn <a href='https://doc.rust-lang.org/nightly/core/ops/deref/trait.DerefMut.html#tymethod.deref_mut' class='fnname'>deref_mut</a>(&amp;mut self) -&gt; &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#933' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Mutably dereferences the value.</p>
</div></div><h3 id='impl-Debug' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl-Debug' class='anchor'></a><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#913-921' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fmt' class="method hidden"><code id='fmt.v'>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class='srclink' href='../../../src/regex_syntax/hir/literal/mod.rs.html#914-920' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>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></p>
</div></div></div><h2 id='synthetic-implementations' class='small-section-header'>Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a></h2><div id='synthetic-implementations-list'><h3 id='impl-Send' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl-Send' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Sync' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../regex_syntax/hir/literal/struct.Literal.html" title="struct regex_syntax::hir::literal::Literal">Literal</a></code><a href='#impl-Sync' class='anchor'></a></h3><div class='impl-items'></div></div><h2 id='blanket-implementations' class='small-section-header'>Blanket Implementations<a href='#blanket-implementations' class='anchor'></a></h2><div id='blanket-implementations-list'><h3 id='impl-From%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</code><a href='#impl-From%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#546-548' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from' class="method hidden"><code id='from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -&gt; T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#547' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-ToOwned' class='impl'><code class='in-band'>impl&lt;T&gt; <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>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></code><a href='#impl-ToOwned' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#81-92' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Owned' class="type"><code id='Owned.t'>type <a href='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned' class="type">Owned</a> = T</code></h4><div class='docblock'><p>The resulting type after obtaining ownership.</p>
</div><h4 id='method.to_owned' class="method hidden"><code id='to_owned.v'>fn <a href='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned' class='fnname'>to_owned</a>(&amp;self) -&gt; T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#85-87' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
</div><h4 id='method.clone_into' class="method hidden"><code id='clone_into.v'>fn <a href='https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into' class='fnname'>clone_into</a>(&amp;self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T)</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#89-91' title='goto source code'>[src]</a></h4><div class='stability hidden'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code>)</summary><p>recently added</p>
</details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
</div></div><h3 id='impl-Into%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-Into%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#537-542' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.into' class="method hidden"><code id='into.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -&gt; U</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#539-541' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryFrom%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryFrom%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#565-571' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><code id='Error.t'>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_from' class="method hidden"><code id='try_from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#568-570' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryInto%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryInto%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#553-560' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><code id='Error.t-1'>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_into' class="method hidden"><code id='try_into.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#557-559' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-BorrowMut%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-BorrowMut%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method hidden"><code id='borrow_mut.v'>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut' class='fnname'>borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#219' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div><h3 id='impl-Borrow%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Borrow%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#213-215' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow' class="method hidden"><code id='borrow.v'>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id='impl-Any' class='impl'><code class='in-band'>impl&lt;T&gt; <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>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Any' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#100-102' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.type_id' class="method hidden"><code id='type_id.v'>fn <a href='https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id' class='fnname'>type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#101' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../../";window.currentCrate = "regex_syntax";</script><script src="../../../aliases.js"></script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>