diff options
author | 2015-06-29 20:16:15 +0000 | |
---|---|---|
committer | 2015-06-29 20:16:15 +0000 | |
commit | 64106c4d3d4ddba8c7bc2af75376e6d3d3d75601 (patch) | |
tree | 8c64d6e8be006486d975a651505fbbde61365cd6 /regex_syntax/struct.CharClass.html | |
download | irsc-64106c4d3d4ddba8c7bc2af75376e6d3d3d75601.tar.gz irsc-64106c4d3d4ddba8c7bc2af75376e6d3d3d75601.tar.xz irsc-64106c4d3d4ddba8c7bc2af75376e6d3d3d75601.zip |
Update documentationgh-pages
Diffstat (limited to 'regex_syntax/struct.CharClass.html')
-rw-r--r-- | regex_syntax/struct.CharClass.html | 493 |
1 files changed, 493 insertions, 0 deletions
diff --git a/regex_syntax/struct.CharClass.html b/regex_syntax/struct.CharClass.html new file mode 100644 index 0000000..9e6ebfc --- /dev/null +++ b/regex_syntax/struct.CharClass.html @@ -0,0 +1,493 @@ +<!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 `CharClass` struct in crate `regex_syntax`."> + <meta name="keywords" content="rust, rustlang, rust-lang, CharClass"> + + <title>regex_syntax::CharClass - Rust</title> + + <link rel="stylesheet" type="text/css" href="../main.css"> + + + +</head> +<body class="rustdoc"> + <!--[if lte IE 8]> + <div class="warning"> + This old browser is unsupported and will most likely display funky + things. + </div> + <![endif]--> + + + + <section class="sidebar"> + + <p class='location'><a href='index.html'>regex_syntax</a></p><script>window.sidebarCurrent = {name: 'CharClass', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script> + </section> + + <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 struct"> +<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>regex_syntax</a>::<wbr><a class='struct' href=''>CharClass</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 id='src-41805' class='srclink' href='../src/regex_syntax/lib.rs.html#200-203' title='goto source code'>[src]</a></span></h1> +<pre class='rust struct'>pub struct CharClass { + // some fields omitted +}</pre><div class='docblock'><p>A character class.</p> + +<p>A character class has a canonical format that the parser guarantees. Its +canonical format is defined by the following invariants:</p> + +<ol> +<li>Given any Unicode scalar value, it is matched by <em>at most</em> one character +range in a canonical character class.</li> +<li>Every adjacent character range is separated by at least one Unicode +scalar value.</li> +<li>Given any pair of character ranges <code>r1</code> and <code>r2</code>, if +<code>r1.end < r2.start</code>, then <code>r1</code> comes before <code>r2</code> in a canonical +character class.</li> +</ol> + +<p>In sum, any <code>CharClass</code> produced by this crate's parser is a sorted +sequence of non-overlapping ranges. This makes it possible to test whether +a character is matched by a class with a binary search.</p> + +<p>Additionally, a character class may be marked <em>case insensitive</em>. If it's +case insensitive, then:</p> + +<ol> +<li>Simple case folding has been applied to all ranges.</li> +<li>Simple case folding must be applied to a character before testing +whether it matches the character class.</li> +</ol> +</div><h2 id='methods'>Methods</h2><h3 class='impl'><code>impl <a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a></code></h3><div class='impl-items'><h4 id='method.matches' class='method'><code>fn <a href='#method.matches' class='fnname'>matches</a>(&self, c: <a href='http://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>) -> <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4> +<div class='docblock'><p>Returns true if <code>c</code> is matched by this character class.</p> + +<p>If this character class is case insensitive, then simple case folding +is applied to <code>c</code> before checking for a match.</p> +</div><h4 id='method.is_case_insensitive' class='method'><code>fn <a href='#method.is_case_insensitive' class='fnname'>is_case_insensitive</a>(&self) -> <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4> +<div class='docblock'><p>Returns true if this character class should be matched case +insensitively.</p> + +<p>When <code>true</code>, simple case folding has already been applied to the +class.</p> +</div></div><h2 id='deref-methods'>Methods from <a class='trait' href='http://doc.rust-lang.org/nightly/core/ops/trait.Deref.html' title='core::ops::Deref'>Deref</a><Target=<a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a><<a class='struct' href='../regex_syntax/struct.ClassRange.html' title='regex_syntax::ClassRange'>ClassRange</a>>></h2><div class='impl-items'><h4 id='method.capacity' class='method'><code>fn <a href='#method.capacity' class='fnname'>capacity</a>(&self) -> <a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code></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'><code>fn <a href='#method.reserve' class='fnname'>reserve</a>(&mut self, additional: <a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>)</code></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.</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" class='section-header'><a + href="#examples">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'><code>fn <a href='#method.reserve_exact' class='fnname'>reserve_exact</a>(&mut self, additional: <a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>)</code></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>. 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" class='section-header'><a + href="#panics">Panics</a></h1> +<p>Panics if the new capacity overflows <code>usize</code>.</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='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'><code>fn <a href='#method.shrink_to_fit' class='fnname'>shrink_to_fit</a>(&mut self)</code></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" class='section-header'><a + href="#examples">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'><code>fn <a href='#method.into_boxed_slice' class='fnname'>into_boxed_slice</a>(self) -> <a class='struct' href='http://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html' title='alloc::boxed::Box'>Box</a><<a href='http://doc.rust-lang.org/nightly/std/primitive.slice.html'>[T]</a>></code></h4> +<div class='docblock'><p>Converts the vector into Box<[T]>.</p> + +<p>Note that this will drop any excess capacity. Calling this and +converting back to a vector with <code>into_vec()</code> is equivalent to calling +<code>shrink_to_fit()</code>.</p> +</div><h4 id='method.truncate' class='method'><code>fn <a href='#method.truncate' class='fnname'>truncate</a>(&mut self, len: <a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>)</code></h4> +<div class='docblock'><p>Shorten a vector, dropping excess elements.</p> + +<p>If <code>len</code> is greater than the vector's current length, this has no +effect.</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='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'>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><h4 id='method.as_slice' class='method'><code>fn <a href='#method.as_slice' class='fnname'>as_slice</a>(&self) -> <a href='http://doc.rust-lang.org/nightly/std/primitive.slice.html'>&[T]</a></code></h4> +<div class='stability'><em class='stab unstable'>Unstable<p>: waiting on RFC revision</p> +</em></div><div class='docblock'><p>Extracts a slice containing the entire vector.</p> + +<p>Equivalent to <code>&s[..]</code>.</p> +</div><h4 id='method.as_mut_slice' class='method'><code>fn <a href='#method.as_mut_slice' class='fnname'>as_mut_slice</a>(&mut self) -> <a href='http://doc.rust-lang.org/nightly/std/primitive.slice.html'>&mut [T]</a></code></h4> +<div class='stability'><em class='stab unstable'>Unstable<p>: waiting on RFC revision</p> +</em></div><div class='docblock'><p>Extracts a mutable slice of the entire vector.</p> + +<p>Equivalent to <code>&mut s[..]</code>.</p> +</div><h4 id='method.set_len' class='method'><code>unsafe fn <a href='#method.set_len' class='fnname'>set_len</a>(&mut self, len: <a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>)</code></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" class='section-header'><a + href="#examples">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='number'>4</span>]; +<span class='kw'>unsafe</span> { + <span class='ident'>v</span>.<span class='ident'>set_len</span>(<span class='number'>1</span>); +} +</pre> +</div><h4 id='method.swap_remove' class='method'><code>fn <a href='#method.swap_remove' class='fnname'>swap_remove</a>(&mut self, index: <a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -> T</code></h4> +<div class='docblock'><p>Removes an element from anywhere in the vector and return it, replacing +it with the last element.</p> + +<p>This does not preserve ordering, but is O(1).</p> + +<h1 id="panics" class='section-header'><a + href="#panics">Panics</a></h1> +<p>Panics if <code>index</code> is out of bounds.</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='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'><code>fn <a href='#method.insert' class='fnname'>insert</a>(&mut self, index: <a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>, element: T)</code></h4> +<div class='docblock'><p>Inserts an element at position <code>index</code> within the vector, shifting all +elements after position <code>i</code> one position to the right.</p> + +<h1 id="panics" class='section-header'><a + href="#panics">Panics</a></h1> +<p>Panics if <code>index</code> is greater than the vector's length.</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='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'><code>fn <a href='#method.remove' class='fnname'>remove</a>(&mut self, index: <a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -> T</code></h4> +<div class='docblock'><p>Removes and returns the element at position <code>index</code> within the vector, +shifting all elements after position <code>index</code> one position to the left.</p> + +<h1 id="panics" class='section-header'><a + href="#panics">Panics</a></h1> +<p>Panics if <code>index</code> is out of bounds.</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='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'><code>fn <a href='#method.retain' class='fnname'>retain</a><F>(&mut self, f: F) <span class='where'>where F: <a class='trait' href='http://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(&T) -> <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></span></code></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 false. +This method operates in place and preserves the order of the retained +elements.</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='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.push' class='method'><code>fn <a href='#method.push' class='fnname'>push</a>(&mut self, value: T)</code></h4> +<div class='docblock'><p>Appends an element to the back of a collection.</p> + +<h1 id="panics" class='section-header'><a + href="#panics">Panics</a></h1> +<p>Panics if the number of elements in the vector overflows a <code>usize</code>.</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='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.pop' class='method'><code>fn <a href='#method.pop' class='fnname'>pop</a>(&mut self) -> <a class='enum' href='http://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><T></code></h4> +<div class='docblock'><p>Removes the last element from a vector and returns it, or <code>None</code> if it is empty.</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='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'><code>fn <a href='#method.append' class='fnname'>append</a>(&mut self, other: &mut <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a><T>)</code></h4> +<div class='stability'><em class='stab unstable'>Unstable<p>: new API, waiting for dust to settle</p> +</em></div><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" class='section-header'><a + href="#panics">Panics</a></h1> +<p>Panics if the number of elements in the vector overflows a <code>usize</code>.</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='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'><code>fn <a href='#method.drain' class='fnname'>drain</a><R>(&mut self, range: R) -> <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Drain.html' title='collections::vec::Drain'>Drain</a><T> <span class='where'>where R: <a class='trait' href='http://doc.rust-lang.org/nightly/collections/range/trait.RangeArgument.html' title='collections::range::RangeArgument'>RangeArgument</a><<a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>></span></code></h4> +<div class='stability'><em class='stab unstable'>Unstable<p>: recently added, matches RFC</p> +</em></div><div class='docblock'><p>Create a draining iterator that removes the specified range in the vector +and yields the removed items from start to end. The element range is +removed even if the iterator is not consumed until the end.</p> + +<p>Note: It is unspecified how many elements are removed from the vector, +if the <code>Drain</code> value is leaked.</p> + +<h1 id="panics" class='section-header'><a + href="#panics">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" class='section-header'><a + href="#examples">Examples</a></h1><pre class='rust rust-example-rendered'> + +<span class='comment'>// Draining using `..` clears the whole vector.</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'>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='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='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>, <span class='number'>3</span>]); +</pre> +</div><h4 id='method.clear' class='method'><code>fn <a href='#method.clear' class='fnname'>clear</a>(&mut self)</code></h4> +<div class='docblock'><p>Clears the vector, removing all values.</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='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'><code>fn <a href='#method.len' class='fnname'>len</a>(&self) -> <a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code></h4> +<div class='docblock'><p>Returns the number of elements in the vector.</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'>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'><code>fn <a href='#method.is_empty' class='fnname'>is_empty</a>(&self) -> <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4> +<div class='docblock'><p>Returns <code>true</code> if the vector contains no elements.</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='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.map_in_place' class='method'><code>fn <a href='#method.map_in_place' class='fnname'>map_in_place</a><U, F>(self, f: F) -> <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a><U> <span class='where'>where F: <a class='trait' href='http://doc.rust-lang.org/nightly/core/ops/trait.FnMut.html' title='core::ops::FnMut'>FnMut</a>(T) -> U</span></code></h4> +<div class='stability'><em class='stab unstable'>Unstable<p>: API may change to provide stronger guarantees</p> +</em></div><div class='docblock'><p>Converts a <code>Vec<T></code> to a <code>Vec<U></code> where <code>T</code> and <code>U</code> have the same +size and in case they are not zero-sized the same minimal alignment.</p> + +<h1 id="panics" class='section-header'><a + href="#panics">Panics</a></h1> +<p>Panics if <code>T</code> and <code>U</code> have differing sizes or are not zero-sized and +have differing minimal alignments.</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'>v</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>0</span>, <span class='number'>1</span>, <span class='number'>2</span>]; +<span class='kw'>let</span> <span class='ident'>w</span> <span class='op'>=</span> <span class='ident'>v</span>.<span class='ident'>map_in_place</span>(<span class='op'>|</span><span class='ident'>i</span><span class='op'>|</span> <span class='ident'>i</span> <span class='op'>+</span> <span class='number'>3</span>); +<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>w</span>[..], <span class='kw-2'>&</span>[<span class='number'>3</span>, <span class='number'>4</span>, <span class='number'>5</span>]); + +<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>PartialEq</span>, <span class='ident'>Debug</span>)]</span> +<span class='kw'>struct</span> <span class='ident'>Newtype</span>(<span class='ident'>u8</span>); +<span class='kw'>let</span> <span class='ident'>bytes</span> <span class='op'>=</span> <span class='macro'>vec</span><span class='macro'>!</span>[<span class='number'>0x11</span>, <span class='number'>0x22</span>]; +<span class='kw'>let</span> <span class='ident'>newtyped_bytes</span> <span class='op'>=</span> <span class='ident'>bytes</span>.<span class='ident'>map_in_place</span>(<span class='op'>|</span><span class='ident'>x</span><span class='op'>|</span> <span class='ident'>Newtype</span>(<span class='ident'>x</span>)); +<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&</span><span class='ident'>newtyped_bytes</span>[..], <span class='kw-2'>&</span>[<span class='ident'>Newtype</span>(<span class='number'>0x11</span>), <span class='ident'>Newtype</span>(<span class='number'>0x22</span>)]); +</pre> +</div><h4 id='method.split_off' class='method'><code>fn <a href='#method.split_off' class='fnname'>split_off</a>(&mut self, at: <a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -> <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a><T></code></h4> +<div class='stability'><em class='stab unstable'>Unstable<p>: new API, waiting for dust to settle</p> +</em></div><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" class='section-header'><a + href="#panics">Panics</a></h1> +<p>Panics if <code>at > len</code>.</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='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'><code>fn <a href='#method.resize' class='fnname'>resize</a>(&mut self, new_len: <a href='http://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>, value: T)</code></h4> +<div class='stability'><em class='stab unstable'>Unstable<p>: matches collection reform specification; waiting for dust to settle</p> +</em></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>Calls either <code>extend()</code> or <code>truncate()</code> depending on whether <code>new_len</code> +is larger than the current value of <code>len()</code> or not.</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='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.push_all' class='method'><code>fn <a href='#method.push_all' class='fnname'>push_all</a>(&mut self, other: <a href='http://doc.rust-lang.org/nightly/std/primitive.slice.html'>&[T]</a>)</code></h4> +<div class='stability'><em class='stab unstable'>Unstable<p>: likely to be replaced by a more optimized extend</p> +</em></div><div class='docblock'><p>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> + +<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='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'>push_all</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.dedup' class='method'><code>fn <a href='#method.dedup' class='fnname'>dedup</a>(&mut self)</code></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" class='section-header'><a + href="#examples">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></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><code>impl <a class='trait' href='http://doc.rust-lang.org/nightly/core/ops/trait.Deref.html' title='core::ops::Deref'>Deref</a> for <a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a></code></h3><div class='impl-items'><h4 id='assoc_type.Target' class='type'><code>type Target = <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a><<a class='struct' href='../regex_syntax/struct.ClassRange.html' title='regex_syntax::ClassRange'>ClassRange</a>></code></h4> +<h4 id='method.deref' class='method'><code>fn <a href='http://doc.rust-lang.org/nightly/core/ops/trait.Deref.html#method.deref' class='fnname'>deref</a>(&self) -> &<a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a><<a class='struct' href='../regex_syntax/struct.ClassRange.html' title='regex_syntax::ClassRange'>ClassRange</a>></code></h4> +</div><h3 class='impl'><code>impl <a class='trait' href='http://doc.rust-lang.org/nightly/core/iter/trait.IntoIterator.html' title='core::iter::IntoIterator'>IntoIterator</a> for <a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a></code></h3><div class='impl-items'><h4 id='assoc_type.Item' class='type'><code>type Item = <a class='struct' href='../regex_syntax/struct.ClassRange.html' title='regex_syntax::ClassRange'>ClassRange</a></code></h4> +<h4 id='assoc_type.IntoIter' class='type'><code>type IntoIter = <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.IntoIter.html' title='collections::vec::IntoIter'>IntoIter</a><<a class='struct' href='../regex_syntax/struct.ClassRange.html' title='regex_syntax::ClassRange'>ClassRange</a>></code></h4> +<h4 id='method.into_iter' class='method'><code>fn <a href='http://doc.rust-lang.org/nightly/core/iter/trait.IntoIterator.html#method.into_iter' class='fnname'>into_iter</a>(self) -> <a class='struct' href='http://doc.rust-lang.org/nightly/collections/vec/struct.IntoIter.html' title='collections::vec::IntoIter'>IntoIter</a><<a class='struct' href='../regex_syntax/struct.ClassRange.html' title='regex_syntax::ClassRange'>ClassRange</a>></code></h4> +</div><h3 class='impl'><code>impl<'a> <a class='trait' href='http://doc.rust-lang.org/nightly/core/iter/trait.IntoIterator.html' title='core::iter::IntoIterator'>IntoIterator</a> for &'a <a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a></code></h3><div class='impl-items'><h4 id='assoc_type.Item' class='type'><code>type Item = &'a <a class='struct' href='../regex_syntax/struct.ClassRange.html' title='regex_syntax::ClassRange'>ClassRange</a></code></h4> +<h4 id='assoc_type.IntoIter' class='type'><code>type IntoIter = <a class='struct' href='http://doc.rust-lang.org/nightly/core/slice/struct.Iter.html' title='core::slice::Iter'>Iter</a><'a, <a class='struct' href='../regex_syntax/struct.ClassRange.html' title='regex_syntax::ClassRange'>ClassRange</a>></code></h4> +<h4 id='method.into_iter' class='method'><code>fn <a href='http://doc.rust-lang.org/nightly/core/iter/trait.IntoIterator.html#method.into_iter' class='fnname'>into_iter</a>(self) -> <a class='struct' href='http://doc.rust-lang.org/nightly/core/slice/struct.Iter.html' title='core::slice::Iter'>Iter</a><'a, <a class='struct' href='../regex_syntax/struct.ClassRange.html' title='regex_syntax::ClassRange'>ClassRange</a>></code></h4> +</div><h3 class='impl'><code>impl <a class='trait' href='http://doc.rust-lang.org/nightly/core/fmt/trait.Display.html' title='core::fmt::Display'>Display</a> for <a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a></code></h3><div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='http://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#method.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class='struct' href='http://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -> <a class='type' href='http://doc.rust-lang.org/nightly/core/fmt/type.Result.html' title='core::fmt::Result'>Result</a></code></h4> +</div><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><code>impl <a class='trait' href='http://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html' title='core::cmp::Eq'>Eq</a> for <a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a></code></h3><div class='impl-items'></div><h3 class='impl'><code>impl <a class='trait' href='http://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a> for <a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a></code></h3><div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='http://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.eq' class='fnname'>eq</a>(&self, __arg_0: &<a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a>) -> <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4> +<h4 id='method.ne' class='method'><code>fn <a href='http://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&self, __arg_0: &<a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a>) -> <a href='http://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4> +</div><h3 class='impl'><code>impl <a class='trait' href='http://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html' title='core::fmt::Debug'>Debug</a> for <a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a></code></h3><div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='http://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#method.fmt' class='fnname'>fmt</a>(&self, __arg_0: &mut <a class='struct' href='http://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -> <a class='type' href='http://doc.rust-lang.org/nightly/core/fmt/type.Result.html' title='core::fmt::Result'>Result</a></code></h4> +</div><h3 class='impl'><code>impl <a class='trait' href='http://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a></code></h3><div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='http://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone' class='fnname'>clone</a>(&self) -> <a class='struct' href='../regex_syntax/struct.CharClass.html' title='regex_syntax::CharClass'>CharClass</a></code></h4> +<h4 id='method.clone_from' class='method'><code>fn <a href='http://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&mut self, source: &Self)</code></h4> +</div></section> + <section id='search' class="content hidden"></section> + + <section class="footer"></section> + + <div id="help" class="hidden"> + <div class="shortcuts"> + <h1>Keyboard shortcuts</h1> + <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> + </dl> + </div> + <div class="infos"> + <h1>Search tricks</h1> + <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>typedef</code> (or + <code>tdef</code>). + </p> + <p> + Search functions by type signature (e.g. + <code>vec -> usize</code>) + </p> + </div> + </div> + + + + <script> + window.rootPath = "../"; + window.currentCrate = "regex_syntax"; + window.playgroundUrl = ""; + </script> + <script src="../jquery.js"></script> + <script src="../main.js"></script> + + <script async src="../search-index.js"></script> +</body> +</html>
\ No newline at end of file |