664 lines
76 KiB
HTML
664 lines
76 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta name="generator" content="rustdoc">
|
||
<meta name="description" content="API documentation for the Rust `Lit` struct in crate `regex_syntax`.">
|
||
<meta name="keywords" content="rust, rustlang, rust-lang, Lit">
|
||
|
||
<title>regex_syntax::Lit - Rust</title>
|
||
|
||
<link rel="stylesheet" type="text/css" href="../normalize.css">
|
||
<link rel="stylesheet" type="text/css" href="../rustdoc.css">
|
||
<link rel="stylesheet" type="text/css" href="../main.css">
|
||
|
||
|
||
|
||
|
||
</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">
|
||
|
||
<p class='location'>Struct Lit</p><div class="block items"><ul><li><a href="#methods">Methods</a></li><li><a href="#deref-methods">Methods from Deref<Target=Vec<u8>></a></li><li><a href="#implementations">Trait Implementations</a></li></ul></div><p class='location'><a href='index.html'>regex_syntax</a></p><script>window.sidebarCurrent = {name: 'Lit', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
|
||
</nav>
|
||
|
||
<nav class="sub">
|
||
<form class="search-form js-only">
|
||
<div class="search-container">
|
||
<input class="search-input" name="search"
|
||
autocomplete="off"
|
||
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
|
||
type="search">
|
||
</div>
|
||
</form>
|
||
</nav>
|
||
|
||
<section id='main' class="content">
|
||
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>regex_syntax</a>::<wbr><a class="struct" href=''>Lit</a></span><span class='out-of-band'><span id='render-detail'>
|
||
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
|
||
[<span class='inner'>−</span>]
|
||
</a>
|
||
</span><a class='srclink' href='../src/regex_syntax/literals.rs.html#45-48' title='goto source code'>[src]</a></span></h1>
|
||
<pre class='rust struct'>pub struct Lit { /* fields omitted */ }</pre><div class='docblock'><p>A single member of a set of literals extracted from a regular expression.</p>
|
||
|
||
<p>This type has <code>Deref</code> and <code>DerefMut</code> impls to <code>Vec<u8></code> so that all slice
|
||
and <code>Vec</code> operations are available.</p>
|
||
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class="struct" href="../regex_syntax/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/regex_syntax/literals.rs.html#866-886' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><code>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><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>>) -> <a class="struct" href="../regex_syntax/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span></h4>
|
||
<div class='docblock'><p>Returns a new complete literal with the bytes given.</p>
|
||
</div><h4 id='method.empty' class="method"><span id='empty.v' class='invisible'><code>fn <a href='#method.empty' class='fnname'>empty</a>() -> <a class="struct" href="../regex_syntax/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span></h4>
|
||
<div class='docblock'><p>Returns a new complete empty literal.</p>
|
||
</div><h4 id='method.is_cut' class="method"><span id='is_cut.v' class='invisible'><code>fn <a href='#method.is_cut' class='fnname'>is_cut</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h4>
|
||
<div class='docblock'><p>Returns true if this literal was "cut."</p>
|
||
</div><h4 id='method.cut' class="method"><span id='cut.v' class='invisible'><code>fn <a href='#method.cut' class='fnname'>cut</a>(&mut self)</code></span></h4>
|
||
<div class='docblock'><p>Cuts this literal.</p>
|
||
</div></div><h2 id='deref-methods'>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><Target = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>>></h2><div class='impl-items'><h4 id='method.capacity' class="method"><span id='capacity.v' class='invisible'><code>fn <a href='#method.capacity' class='fnname'>capacity</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">vec</span>: <span class="ident">Vec</span><span class="op"><</span><span class="ident">i32</span><span class="op">></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><h4 id='method.reserve' class="method"><span id='reserve.v' class='invisible'><code>fn <a href='#method.reserve' class='fnname'>reserve</a>(&mut self, additional: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></h4>
|
||
<div class='docblock'><p>Reserves capacity for at least <code>additional</code> more elements to be inserted
|
||
in the given <code>Vec<T></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>
|
||
<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">>=</span> <span class="number">11</span>);</pre>
|
||
</div><h4 id='method.reserve_exact' class="method"><span id='reserve_exact.v' class='invisible'><code>fn <a href='#method.reserve_exact' class='fnname'>reserve_exact</a>(&mut self, additional: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></h4>
|
||
<div class='docblock'><p>Reserves the minimum capacity for exactly <code>additional</code> more elements to
|
||
be inserted in the given <code>Vec<T></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>
|
||
<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">>=</span> <span class="number">11</span>);</pre>
|
||
</div><h4 id='method.shrink_to_fit' class="method"><span id='shrink_to_fit.v' class='invisible'><code>fn <a href='#method.shrink_to_fit' class='fnname'>shrink_to_fit</a>(&mut self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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-3' class='section-header'><a href='#examples-3'>Examples</a></h1>
|
||
<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">>=</span> <span class="number">3</span>);</pre>
|
||
</div><h4 id='method.into_boxed_slice' class="method"><span id='into_boxed_slice.v' class='invisible'><code>fn <a href='#method.into_boxed_slice' class='fnname'>into_boxed_slice</a>(self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a>T<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></h4>
|
||
<div class='docblock'><p>Converts the vector into <a href="../../std/boxed/struct.Box.html"><code>Box<[T]></code></a>.</p>
|
||
|
||
<p>Note that this will drop any excess capacity. Calling this and
|
||
converting back to a vector with <a href="../../std/primitive.slice.html#method.into_vec"><code>into_vec</code></a> is equivalent to calling
|
||
<a href="#method.shrink_to_fit"><code>shrink_to_fit</code></a>.</p>
|
||
|
||
<h1 id='examples-4' class='section-header'><a href='#examples-4'>Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">let</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">slice</span> <span class="op">=</span> <span class="ident">v</span>.<span class="ident">into_boxed_slice</span>();</pre>
|
||
|
||
<p>Any excess capacity is removed:</p>
|
||
|
||
<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="kw">let</span> <span class="ident">slice</span> <span class="op">=</span> <span class="ident">vec</span>.<span class="ident">into_boxed_slice</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">slice</span>.<span class="ident">into_vec</span>().<span class="ident">capacity</span>(), <span class="number">3</span>);</pre>
|
||
</div><h4 id='method.truncate' class="method"><span id='truncate.v' class='invisible'><code>fn <a href='#method.truncate' class='fnname'>truncate</a>(&mut self, len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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-5' class='section-header'><a href='#examples-5'>Examples</a></h1>
|
||
<p>Truncating a five element vector to two elements:</p>
|
||
|
||
<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>
|
||
|
||
<p>No truncation occurs when <code>len</code> is greater than the vector's current
|
||
length:</p>
|
||
|
||
<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>
|
||
|
||
<p>Truncating when <code>len == 0</code> is equivalent to calling the <a href="#method.clear"><code>clear</code></a>
|
||
method.</p>
|
||
|
||
<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><h4 id='method.as_slice' class="method"><span id='as_slice.v' class='invisible'><code>fn <a href='#method.as_slice' class='fnname'>as_slice</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[T]</a></code><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div></span></h4>
|
||
<div class='docblock'><p>Extracts a slice containing the entire vector.</p>
|
||
|
||
<p>Equivalent to <code>&s[..]</code>.</p>
|
||
|
||
<h1 id='examples-6' class='section-header'><a href='#examples-6'>Examples</a></h1>
|
||
<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><h4 id='method.as_mut_slice' class="method"><span id='as_mut_slice.v' class='invisible'><code>fn <a href='#method.as_mut_slice' class='fnname'>as_mut_slice</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [T]</a></code><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div></span></h4>
|
||
<div class='docblock'><p>Extracts a mutable slice of the entire vector.</p>
|
||
|
||
<p>Equivalent to <code>&mut s[..]</code>.</p>
|
||
|
||
<h1 id='examples-7' class='section-header'><a href='#examples-7'>Examples</a></h1>
|
||
<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><h4 id='method.set_len' class="method"><span id='set_len.v' class='invisible'><code>unsafe fn <a href='#method.set_len' class='fnname'>set_len</a>(&mut self, len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></h4>
|
||
<div class='docblock'><p>Sets the length of a vector.</p>
|
||
|
||
<p>This will explicitly set the size of the vector, without actually
|
||
modifying its buffers, so it is up to the caller to ensure that the
|
||
vector is actually the specified size.</p>
|
||
|
||
<h1 id='examples-8' class='section-header'><a href='#examples-8'>Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ptr</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="string">'r'</span>, <span class="string">'u'</span>, <span class="string">'s'</span>, <span class="string">'t'</span>];
|
||
|
||
<span class="kw">unsafe</span> {
|
||
<span class="ident">ptr</span>::<span class="ident">drop_in_place</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">vec</span>[<span class="number">3</span>]);
|
||
<span class="ident">vec</span>.<span class="ident">set_len</span>(<span class="number">3</span>);
|
||
}
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="string">'r'</span>, <span class="string">'u'</span>, <span class="string">'s'</span>]);</pre>
|
||
|
||
<p>In this example, there is a memory leak since the memory locations
|
||
owned by the inner vectors were not freed prior to the <code>set_len</code> call:</p>
|
||
|
||
<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="kw">unsafe</span> {
|
||
<span class="ident">vec</span>.<span class="ident">set_len</span>(<span class="number">0</span>);
|
||
}</pre>
|
||
|
||
<p>In this example, the vector gets expanded from zero to four items
|
||
without any memory allocations occurring, resulting in vector
|
||
values of unallocated memory:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span>: <span class="ident">Vec</span><span class="op"><</span><span class="ident">char</span><span class="op">></span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">new</span>();
|
||
|
||
<span class="kw">unsafe</span> {
|
||
<span class="ident">vec</span>.<span class="ident">set_len</span>(<span class="number">4</span>);
|
||
}</pre>
|
||
</div><h4 id='method.swap_remove' class="method"><span id='swap_remove.v' class='invisible'><code>fn <a href='#method.swap_remove' class='fnname'>swap_remove</a>(&mut self, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> T</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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-9' class='section-header'><a href='#examples-9'>Examples</a></h1>
|
||
<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">"foo"</span>, <span class="string">"bar"</span>, <span class="string">"baz"</span>, <span class="string">"qux"</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">"bar"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, [<span class="string">"foo"</span>, <span class="string">"qux"</span>, <span class="string">"baz"</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">"foo"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, [<span class="string">"baz"</span>, <span class="string">"qux"</span>]);</pre>
|
||
</div><h4 id='method.insert' class="method"><span id='insert.v' class='invisible'><code>fn <a href='#method.insert' class='fnname'>insert</a>(&mut self, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, element: T)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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</code> is out of bounds.</p>
|
||
|
||
<h1 id='examples-10' class='section-header'><a href='#examples-10'>Examples</a></h1>
|
||
<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><h4 id='method.remove' class="method"><span id='remove.v' class='invisible'><code>fn <a href='#method.remove' class='fnname'>remove</a>(&mut self, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> T</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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-11' class='section-header'><a href='#examples-11'>Examples</a></h1>
|
||
<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><h4 id='method.retain' class="method"><span id='retain.v' class='invisible'><code>fn <a href='#method.retain' class='fnname'>retain</a><F>(&mut self, f: F) <span class="where fmt-newline">where<br> 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>(&T) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>, </span></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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(&e)</code> returns <code>false</code>.
|
||
This method operates in place and preserves the order of the retained
|
||
elements.</p>
|
||
|
||
<h1 id='examples-12' class='section-header'><a href='#examples-12'>Examples</a></h1>
|
||
<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">&</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><h4 id='method.dedup_by_key' class="method"><span id='dedup_by_key.v' class='invisible'><code>fn <a href='#method.dedup_by_key' class='fnname'>dedup_by_key</a><F, K>(&mut self, key: F) <span class="where fmt-newline">where<br> 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>(&mut T) -> K,<br> K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a><K>, </span></code><div class='since' title='Stable since Rust version 1.16.0'>1.16.0</div></span></h4>
|
||
<div class='docblock'><p>Removes 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-13' class='section-header'><a href='#examples-13'>Examples</a></h1>
|
||
<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><h4 id='method.dedup_by' class="method"><span id='dedup_by.v' class='invisible'><code>fn <a href='#method.dedup_by' class='fnname'>dedup_by</a><F>(&mut self, same_bucket: F) <span class="where fmt-newline">where<br> 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>(&mut T, &mut T) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>, </span></code><div class='since' title='Stable since Rust version 1.16.0'>1.16.0</div></span></h4>
|
||
<div class='docblock'><p>Removes consecutive elements in the vector according to a predicate.</p>
|
||
|
||
<p>The <code>same_bucket</code> function is passed references to two elements from the vector, and
|
||
returns <code>true</code> if the elements compare equal, or <code>false</code> if they do not. Only the first
|
||
of adjacent equal items is kept.</p>
|
||
|
||
<p>If the vector is sorted, this removes all duplicates.</p>
|
||
|
||
<h1 id='examples-14' class='section-header'><a href='#examples-14'>Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ascii</span>::<span class="ident">AsciiExt</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="string">"foo"</span>, <span class="string">"bar"</span>, <span class="string">"Bar"</span>, <span class="string">"baz"</span>, <span class="string">"bar"</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">"foo"</span>, <span class="string">"bar"</span>, <span class="string">"baz"</span>, <span class="string">"bar"</span>]);</pre>
|
||
</div><h4 id='method.push' class="method"><span id='push.v' class='invisible'><code>fn <a href='#method.push' class='fnname'>push</a>(&mut self, value: T)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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-15' class='section-header'><a href='#examples-15'>Examples</a></h1>
|
||
<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><h4 id='method.place_back' class="method"><span id='place_back.v' class='invisible'><code>fn <a href='#method.place_back' class='fnname'>place_back</a>(&mut self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.PlaceBack.html" title="struct alloc::vec::PlaceBack">PlaceBack</a><T></code></span></h4>
|
||
<div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>collection_placement</code>)</summary><p>placement protocol is subject to change</p>
|
||
</details></div></div><div class='docblock'><p>Returns a place for insertion at the back of the <code>Vec</code>.</p>
|
||
|
||
<p>Using this method with placement syntax is equivalent to <a href="#method.push"><code>push</code></a>,
|
||
but may be more efficient.</p>
|
||
|
||
<h1 id='examples-16' class='section-header'><a href='#examples-16'>Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="attribute">#<span class="op">!</span>[<span class="ident">feature</span>(<span class="ident">collection_placement</span>)]</span>
|
||
<span class="attribute">#<span class="op">!</span>[<span class="ident">feature</span>(<span class="ident">placement_in_syntax</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="ident">vec</span>.<span class="ident">place_back</span>() <- <span class="number">3</span>;
|
||
<span class="ident">vec</span>.<span class="ident">place_back</span>() <- <span class="number">4</span>;
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">vec</span>, <span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);</pre>
|
||
</div><h4 id='method.pop' class="method"><span id='pop.v' class='invisible'><code>fn <a href='#method.pop' class='fnname'>pop</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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-17' class='section-header'><a href='#examples-17'>Examples</a></h1>
|
||
<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><h4 id='method.append' class="method"><span id='append.v' class='invisible'><code>fn <a href='#method.append' class='fnname'>append</a>(&mut self, other: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>)</code><div class='since' title='Stable since Rust version 1.4.0'>1.4.0</div></span></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-18' class='section-header'><a href='#examples-18'>Examples</a></h1>
|
||
<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">&</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><h4 id='method.drain' class="method"><span id='drain.v' class='invisible'><code>fn <a href='#method.drain' class='fnname'>drain</a><R>(&mut self, range: R) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Drain.html" title="struct alloc::vec::Drain">Drain</a><T> <span class="where fmt-newline">where<br> R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/range/trait.RangeArgument.html" title="trait core::ops::range::RangeArgument">RangeArgument</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>, </span></code><div class='since' title='Stable since Rust version 1.6.0'>1.6.0</div></span></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-19' class='section-header'><a href='#examples-19'>Examples</a></h1>
|
||
<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"><</span>_<span class="op">></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">&</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">&</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">&</span>[]);</pre>
|
||
</div><h4 id='method.clear' class="method"><span id='clear.v' class='invisible'><code>fn <a href='#method.clear' class='fnname'>clear</a>(&mut self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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-20' class='section-header'><a href='#examples-20'>Examples</a></h1>
|
||
<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><h4 id='method.len' class="method"><span id='len.v' class='invisible'><code>fn <a href='#method.len' class='fnname'>len</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></h4>
|
||
<div class='docblock'><p>Returns the number of elements in the vector, also referred to
|
||
as its 'length'.</p>
|
||
|
||
<h1 id='examples-21' class='section-header'><a href='#examples-21'>Examples</a></h1>
|
||
<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><h4 id='method.is_empty' class="method"><span id='is_empty.v' class='invisible'><code>fn <a href='#method.is_empty' class='fnname'>is_empty</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></h4>
|
||
<div class='docblock'><p>Returns <code>true</code> if the vector contains no elements.</p>
|
||
|
||
<h1 id='examples-22' class='section-header'><a href='#examples-22'>Examples</a></h1>
|
||
<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><h4 id='method.split_off' class="method"><span id='split_off.v' class='invisible'><code>fn <a href='#method.split_off' class='fnname'>split_off</a>(&mut self, at: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T></code><div class='since' title='Stable since Rust version 1.4.0'>1.4.0</div></span></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 > len</code>.</p>
|
||
|
||
<h1 id='examples-23' class='section-header'><a href='#examples-23'>Examples</a></h1>
|
||
<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><div class='impl-items'><h4 id='method.resize' class="method"><span id='resize.v' class='invisible'><code>fn <a href='#method.resize' class='fnname'>resize</a>(&mut self, new_len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, value: T)</code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></span></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 <code>Clone</code> to clone the passed value. If you'd
|
||
rather create a value with <code>Default</code> instead, see <a href="#method.resize_default"><code>resize_default</code></a>.</p>
|
||
|
||
<h1 id='examples-24' class='section-header'><a href='#examples-24'>Examples</a></h1>
|
||
<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">"hello"</span>];
|
||
<span class="ident">vec</span>.<span class="ident">resize</span>(<span class="number">3</span>, <span class="string">"world"</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">vec</span>, [<span class="string">"hello"</span>, <span class="string">"world"</span>, <span class="string">"world"</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><h4 id='method.extend_from_slice' class="method"><span id='extend_from_slice.v' class='invisible'><code>fn <a href='#method.extend_from_slice' class='fnname'>extend_from_slice</a>(&mut self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[T]</a>)</code><div class='since' title='Stable since Rust version 1.6.0'>1.6.0</div></span></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 <code>extend</code> 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-25' class='section-header'><a href='#examples-25'>Examples</a></h1>
|
||
<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">&</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 class='impl-items'><h4 id='method.resize_default' class="method"><span id='resize_default.v' class='invisible'><code>fn <a href='#method.resize_default' class='fnname'>resize_default</a>(&mut self, new_len: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></span></h4>
|
||
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</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 <code>Default::default()</code>.
|
||
If <code>new_len</code> is less than <code>len</code>, the <code>Vec</code> is simply truncated.</p>
|
||
|
||
<p>This method uses <code>Default</code> to create new values on every push. If
|
||
you'd rather <code>Clone</code> a given value, use <a href="#method.resize"><code>resize</code></a>.</p>
|
||
|
||
<h1 id='examples-26' class='section-header'><a href='#examples-26'>Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="attribute">#<span class="op">!</span>[<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 class='impl-items'><h4 id='method.dedup' class="method"><span id='dedup.v' class='invisible'><code>fn <a href='#method.dedup' class='fnname'>dedup</a>(&mut self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></h4>
|
||
<div class='docblock'><p>Removes consecutive repeated elements in the vector.</p>
|
||
|
||
<p>If the vector is sorted, this removes all duplicates.</p>
|
||
|
||
<h1 id='examples-27' class='section-header'><a href='#examples-27'>Examples</a></h1>
|
||
<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><h4 id='method.remove_item' class="method"><span id='remove_item.v' class='invisible'><code>fn <a href='#method.remove_item' class='fnname'>remove_item</a>(&mut self, item: &T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T></code></span></h4>
|
||
<div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</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-28' class='section-header'><a href='#examples-28'>Examples</a></h1>
|
||
<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">&</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 class='impl-items'><h4 id='method.splice' class="method"><span id='splice.v' class='invisible'><code>fn <a href='#method.splice' class='fnname'>splice</a><R, I>(<br> &mut self, <br> range: R, <br> replace_with: I<br>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Splice.html" title="struct alloc::vec::Splice">Splice</a><<I as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>> <span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a><Item = T>,<br> R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/range/trait.RangeArgument.html" title="trait core::ops::range::RangeArgument">RangeArgument</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>, </span></code></span></h4>
|
||
<div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>splice</code>)</summary><p>recently added</p>
|
||
</details></div></div><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-29' class='section-header'><a href='#examples-29'>Examples</a></h1>
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="attribute">#<span class="op">!</span>[<span class="ident">feature</span>(<span class="ident">splice</span>)]</span>
|
||
<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"><</span>_<span class="op">></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">&</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">&</span>[<span class="number">1</span>, <span class="number">2</span>]);</pre>
|
||
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>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/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/regex_syntax/literals.rs.html#44' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.clone' class="method"><span id='clone.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&self) -> <a class="struct" href="../regex_syntax/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span></h4>
|
||
<div class='docblock'><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"><span id='clone_from.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&mut self, source: &Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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 class='impl'><span class='in-band'><code>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/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/regex_syntax/literals.rs.html#44' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>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/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/regex_syntax/literals.rs.html#44' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.cmp' class="method"><span id='cmp.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp' class='fnname'>cmp</a>(&self, __arg_0: &<a class="struct" href="../regex_syntax/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a></code></span></h4>
|
||
<div class='docblock'><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"><span id='max.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.max' class='fnname'>max</a>(self, other: Self) -> Self</code></span></h4>
|
||
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ord_max_min</code>)</div></div><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"><span id='min.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.min' class='fnname'>min</a>(self, other: Self) -> Self</code></span></h4>
|
||
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ord_max_min</code>)</div></div><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></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="struct" href="../regex_syntax/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/regex_syntax/literals.rs.html#888-892' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.eq' class="method"><span id='eq.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&self, other: &<a class="struct" href="../regex_syntax/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h4>
|
||
<div class='docblock'><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"><span id='ne.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&self, other: &Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></h4>
|
||
<div class='docblock'><p>This method tests for <code>!=</code>.</p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> for <a class="struct" href="../regex_syntax/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/regex_syntax/literals.rs.html#894-898' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.partial_cmp' class="method"><span id='partial_cmp.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp' class='fnname'>partial_cmp</a>(&self, other: &<a class="struct" href="../regex_syntax/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>></code></span></h4>
|
||
<div class='docblock'><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"><span id='lt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt' class='fnname'>lt</a>(&self, other: &Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></h4>
|
||
<div class='docblock'><p>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</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"><span id='le.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le' class='fnname'>le</a>(&self, other: &Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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><=</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"><span id='gt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt' class='fnname'>gt</a>(&self, other: &Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></h4>
|
||
<div class='docblock'><p>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></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"><span id='ge.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge' class='fnname'>ge</a>(&self, other: &Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></span></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>>=</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>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/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/regex_syntax/literals.rs.html#900-908' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></h4>
|
||
<div class='docblock'><p>Formats the value using the given formatter.</p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.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>> for <a class="struct" href="../regex_syntax/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/regex_syntax/literals.rs.html#910-912' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.as_ref' class="method"><span id='as_ref.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref' class='fnname'>as_ref</a>(&self) -> <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></code></span></h4>
|
||
<div class='docblock'><p>Performs the conversion.</p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>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/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/regex_syntax/literals.rs.html#914-917' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='associatedtype.Target' class="type"><span id='Target.t' class='invisible'><code>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><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>></code></span></h4>
|
||
<div class='docblock'><p>The resulting type after dereferencing</p>
|
||
</div><h4 id='method.deref' class="method"><span id='deref.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#tymethod.deref' class='fnname'>deref</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>></code></span></h4>
|
||
<div class='docblock'><p>The method called to dereference a value</p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>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/struct.Lit.html" title="struct regex_syntax::Lit">Lit</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/regex_syntax/literals.rs.html#919-921' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.deref_mut' class="method"><span id='deref_mut.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/deref/trait.DerefMut.html#tymethod.deref_mut' class='fnname'>deref_mut</a>(&mut self) -> &mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>></code></span></h4>
|
||
<div class='docblock'><p>The method called to mutably dereference a value</p>
|
||
</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>?</dt>
|
||
<dd>Show this help dialog</dd>
|
||
<dt>S</dt>
|
||
<dd>Focus the search field</dd>
|
||
<dt>⇤</dt>
|
||
<dd>Move up in search results</dd>
|
||
<dt>⇥</dt>
|
||
<dd>Move down in search results</dd>
|
||
<dt>⏎</dt>
|
||
<dd>Go to active search result</dd>
|
||
<dt>+</dt>
|
||
<dd>Collapse/expand 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>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
|
||
|
||
<script>
|
||
window.rootPath = "../";
|
||
window.currentCrate = "regex_syntax";
|
||
</script>
|
||
<script src="../main.js"></script>
|
||
<script defer src="../search-index.js"></script>
|
||
</body>
|
||
</html> |