juniper/iron/headers/struct.Referer.html
Juniper Documentation Builder 95d942c9d4 Update documentation for Juniper
2016-09-11 18:41:24 +00:00

502 lines
No EOL
46 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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 `Referer` struct in crate `iron`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Referer">
<title>iron::headers::Referer - Rust</title>
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
<link rel="shortcut icon" href="https://avatars0.githubusercontent.com/u/7853871?s=256">
</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]-->
<nav class="sidebar">
<a href='../../iron/index.html'><img src='https://avatars0.githubusercontent.com/u/7853871?s=128' alt='logo' width='100'></a>
<p class='location'><a href='../index.html'>iron</a>::<wbr><a href='index.html'>headers</a></p><script>window.sidebarCurrent = {name: 'Referer', 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 struct">
<h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>iron</a>::<wbr><a href='index.html'>headers</a>::<wbr><a class='struct' href=''>Referer</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'>&#x2212;</span>]
</a>
</span><a id='src-4036' class='srclink' href='../../hyper/header/common/referer/struct.Referer.html?gotosrc=4036' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Referer(pub <a class='struct' href='https://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a>);</pre><div class='docblock'><p><code>Referer</code> header, defined in
<a href="http://tools.ietf.org/html/rfc7231#section-5.5.2">RFC7231</a></p>
<p>The <code>Referer</code> [sic] header field allows the user agent to specify a
URI reference for the resource from which the target URI was obtained
(i.e., the &quot;referrer&quot;, though the field name is misspelled). A user
agent MUST NOT include the fragment and userinfo components of the
URI reference, if any, when generating the Referer field value.</p>
<h1 id='abnf' class='section-header'><a href='#abnf'>ABNF</a></h1>
<pre><code class="language-plain">Referer = absolute-URI / partial-URI
</code></pre>
<h1 id='example-values' class='section-header'><a href='#example-values'>Example values</a></h1>
<ul>
<li><code>http://www.example.org/hypertext/Overview.html</code></li>
</ul>
<h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>hyper</span>::<span class='ident'>header</span>::{<span class='ident'>Headers</span>, <span class='ident'>Referer</span>};
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>headers</span> <span class='op'>=</span> <span class='ident'>Headers</span>::<span class='ident'>new</span>();
<span class='ident'>headers</span>.<span class='ident'>set</span>(<span class='ident'>Referer</span>(<span class='string'>&quot;/People.html#tim&quot;</span>.<span class='ident'>to_owned</span>()));</pre>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>hyper</span>::<span class='ident'>header</span>::{<span class='ident'>Headers</span>, <span class='ident'>Referer</span>};
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>headers</span> <span class='op'>=</span> <span class='ident'>Headers</span>::<span class='ident'>new</span>();
<span class='ident'>headers</span>.<span class='ident'>set</span>(<span class='ident'>Referer</span>(<span class='string'>&quot;http://www.example.com/index.html&quot;</span>.<span class='ident'>to_owned</span>()));</pre>
</div><h2 id='deref-methods'>Methods from <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.Deref.html' title='core::ops::Deref'>Deref</a>&lt;Target=<a class='struct' href='https://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a>&gt;</h2><div class='impl-items'><h4 id='method.into_bytes' class='method'><code>fn <a href='#method.into_bytes' class='fnname'>into_bytes</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a>&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Converts a <code>String</code> into a byte vector.</p>
<p>This consumes the <code>String</code>, so we do not need to copy its contents.</p>
<h1 id='examples-1' class='section-header'><a href='#examples-1'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='kw'>let</span> <span class='ident'>bytes</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>into_bytes</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&amp;</span>[<span class='number'>104</span>, <span class='number'>101</span>, <span class='number'>108</span>, <span class='number'>108</span>, <span class='number'>111</span>][..], <span class='kw-2'>&amp;</span><span class='ident'>bytes</span>[..]);</pre>
</div><h4 id='method.as_str' class='method'><code>fn <a href='#method.as_str' class='fnname'>as_str</a>(&amp;self) -&gt; &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div></h4>
<div class='docblock'><p>Extracts a string slice containing the entire string.</p>
</div><h4 id='method.as_mut_str' class='method'><code>fn <a href='#method.as_mut_str' class='fnname'>as_mut_str</a>(&amp;mut self) -&gt; &amp;mut <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div></h4>
<div class='docblock'><p>Extracts a string slice containing the entire string.</p>
</div><h4 id='method.push_str' class='method'><code>fn <a href='#method.push_str' class='fnname'>push_str</a>(&amp;mut self, string: &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Appends a given string slice onto the end of this <code>String</code>.</p>
<h1 id='examples-2' class='section-header'><a href='#examples-2'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</span>);
<span class='ident'>s</span>.<span class='ident'>push_str</span>(<span class='string'>&quot;bar&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;foobar&quot;</span>, <span class='ident'>s</span>);</pre>
</div><h4 id='method.capacity' class='method'><code>fn <a href='#method.capacity' class='fnname'>capacity</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Returns this <code>String</code>&#39;s capacity, in bytes.</p>
<h1 id='examples-3' class='section-header'><a href='#examples-3'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>10</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>capacity</span>() <span class='op'>&gt;=</span> <span class='number'>10</span>);</pre>
</div><h4 id='method.reserve' class='method'><code>fn <a href='#method.reserve' class='fnname'>reserve</a>(&amp;mut self, additional: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Ensures that this <code>String</code>&#39;s capacity is at least <code>additional</code> bytes
larger than its length.</p>
<p>The capacity may be increased by more than <code>additional</code> bytes if it
chooses, to prevent frequent reallocations.</p>
<p>If you do not want this &quot;at least&quot; behavior, see the <a href="#method.reserve_exact"><code>reserve_exact()</code></a>
method.</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-4' class='section-header'><a href='#examples-4'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>();
<span class='ident'>s</span>.<span class='ident'>reserve</span>(<span class='number'>10</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>capacity</span>() <span class='op'>&gt;=</span> <span class='number'>10</span>);</pre>
<p>This may not actually increase the capacity:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>10</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;a&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;b&#39;</span>);
<span class='comment'>// s now has a length of 2 and a capacity of 10</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>2</span>, <span class='ident'>s</span>.<span class='ident'>len</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>10</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());
<span class='comment'>// Since we already have an extra 8 capacity, calling this...</span>
<span class='ident'>s</span>.<span class='ident'>reserve</span>(<span class='number'>8</span>);
<span class='comment'>// ... doesn&#39;t actually increase.</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>10</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());</pre>
</div><h4 id='method.reserve_exact' class='method'><code>fn <a href='#method.reserve_exact' class='fnname'>reserve_exact</a>(&amp;mut self, additional: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Ensures that this <code>String</code>&#39;s capacity is <code>additional</code> bytes
larger than its length.</p>
<p>Consider using the <a href="#method.reserve"><code>reserve()</code></a> method unless you absolutely know
better than the allocator.</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-5' class='section-header'><a href='#examples-5'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>();
<span class='ident'>s</span>.<span class='ident'>reserve_exact</span>(<span class='number'>10</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>capacity</span>() <span class='op'>&gt;=</span> <span class='number'>10</span>);</pre>
<p>This may not actually increase the capacity:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>10</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;a&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;b&#39;</span>);
<span class='comment'>// s now has a length of 2 and a capacity of 10</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>2</span>, <span class='ident'>s</span>.<span class='ident'>len</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>10</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());
<span class='comment'>// Since we already have an extra 8 capacity, calling this...</span>
<span class='ident'>s</span>.<span class='ident'>reserve_exact</span>(<span class='number'>8</span>);
<span class='comment'>// ... doesn&#39;t actually increase.</span>
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>10</span>, <span class='ident'>s</span>.<span class='ident'>capacity</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>(&amp;mut self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Shrinks the capacity of this <code>String</code> to match its length.</p>
<h1 id='examples-6' class='section-header'><a href='#examples-6'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</span>);
<span class='ident'>s</span>.<span class='ident'>reserve</span>(<span class='number'>100</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>capacity</span>() <span class='op'>&gt;=</span> <span class='number'>100</span>);
<span class='ident'>s</span>.<span class='ident'>shrink_to_fit</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>3</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());</pre>
</div><h4 id='method.push' class='method'><code>fn <a href='#method.push' class='fnname'>push</a>(&amp;mut self, ch: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Appends the given <code>char</code> to the end of this <code>String</code>.</p>
<h1 id='examples-7' class='section-header'><a href='#examples-7'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;abc&quot;</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;1&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;2&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>push</span>(<span class='string'>&#39;3&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;abc123&quot;</span>, <span class='ident'>s</span>);</pre>
</div><h4 id='method.as_bytes' class='method'><code>fn <a href='#method.as_bytes' class='fnname'>as_bytes</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Returns a byte slice of this <code>String</code>&#39;s contents.</p>
<h1 id='examples-8' class='section-header'><a href='#examples-8'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&amp;</span>[<span class='number'>104</span>, <span class='number'>101</span>, <span class='number'>108</span>, <span class='number'>108</span>, <span class='number'>111</span>], <span class='ident'>s</span>.<span class='ident'>as_bytes</span>());</pre>
</div><h4 id='method.truncate' class='method'><code>fn <a href='#method.truncate' class='fnname'>truncate</a>(&amp;mut self, new_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></h4>
<div class='docblock'><p>Shortens this <code>String</code> to the specified length.</p>
<p>If <code>new_len</code> is greater than the string&#39;s current length, this has no
effect.</p>
<h1 id='panics-2' class='section-header'><a href='#panics-2'>Panics</a></h1>
<p>Panics if <code>new_len</code> does not lie on a <a href="../../std/primitive.char.html"><code>char</code></a> boundary.</p>
<h1 id='examples-9' class='section-header'><a href='#examples-9'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='ident'>s</span>.<span class='ident'>truncate</span>(<span class='number'>2</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;he&quot;</span>, <span class='ident'>s</span>);</pre>
</div><h4 id='method.pop' class='method'><code>fn <a href='#method.pop' class='fnname'>pop</a>(&amp;mut self) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Removes the last character from the string buffer and returns it.</p>
<p>Returns <code>None</code> if this <code>String</code> is empty.</p>
<h1 id='examples-10' class='section-header'><a href='#examples-10'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>pop</span>(), <span class='prelude-val'>Some</span>(<span class='string'>&#39;o&#39;</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>pop</span>(), <span class='prelude-val'>Some</span>(<span class='string'>&#39;o&#39;</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>pop</span>(), <span class='prelude-val'>Some</span>(<span class='string'>&#39;f&#39;</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>pop</span>(), <span class='prelude-val'>None</span>);</pre>
</div><h4 id='method.remove' class='method'><code>fn <a href='#method.remove' class='fnname'>remove</a>(&amp;mut self, idx: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Removes a <code>char</code> from this <code>String</code> at a byte position and returns it.</p>
<p>This is an <code>O(n)</code> operation, as it requires copying every element in the
buffer.</p>
<h1 id='panics-3' class='section-header'><a href='#panics-3'>Panics</a></h1>
<p>Panics if <code>idx</code> is larger than or equal to the <code>String</code>&#39;s length,
or if it does not lie on a <a href="../../std/primitive.char.html"><code>char</code></a> boundary.</p>
<h1 id='examples-11' class='section-header'><a href='#examples-11'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>remove</span>(<span class='number'>0</span>), <span class='string'>&#39;f&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>remove</span>(<span class='number'>1</span>), <span class='string'>&#39;o&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>remove</span>(<span class='number'>0</span>), <span class='string'>&#39;o&#39;</span>);</pre>
</div><h4 id='method.insert' class='method'><code>fn <a href='#method.insert' class='fnname'>insert</a>(&amp;mut self, idx: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>, ch: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Inserts a character into this <code>String</code> at a byte position.</p>
<p>This is an <code>O(n)</code> operation as it requires copying every element in the
buffer.</p>
<h1 id='panics-4' class='section-header'><a href='#panics-4'>Panics</a></h1>
<p>Panics if <code>idx</code> is larger than the <code>String</code>&#39;s length, or if it does not
lie on a <a href="../../std/primitive.char.html"><code>char</code></a> boundary.</p>
<h1 id='examples-12' class='section-header'><a href='#examples-12'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>with_capacity</span>(<span class='number'>3</span>);
<span class='ident'>s</span>.<span class='ident'>insert</span>(<span class='number'>0</span>, <span class='string'>&#39;f&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='string'>&#39;o&#39;</span>);
<span class='ident'>s</span>.<span class='ident'>insert</span>(<span class='number'>2</span>, <span class='string'>&#39;o&#39;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='string'>&quot;foo&quot;</span>, <span class='ident'>s</span>);</pre>
</div><h4 id='method.as_mut_vec' class='method'><code>unsafe fn <a href='#method.as_mut_vec' class='fnname'>as_mut_vec</a>(&amp;mut self) -&gt; &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a>&gt;</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Returns a mutable reference to the contents of this <code>String</code>.</p>
<h1 id='safety' class='section-header'><a href='#safety'>Safety</a></h1>
<p>This function is unsafe because it does not check that the bytes passed
to it are valid UTF-8. If this constraint is violated, it may cause
memory unsafety issues with future users of the <code>String</code>, as the rest of
the standard library assumes that <code>String</code>s are valid UTF-8.</p>
<h1 id='examples-13' class='section-header'><a href='#examples-13'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='kw'>unsafe</span> {
<span class='kw'>let</span> <span class='ident'>vec</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>as_mut_vec</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='kw-2'>&amp;</span>[<span class='number'>104</span>, <span class='number'>101</span>, <span class='number'>108</span>, <span class='number'>108</span>, <span class='number'>111</span>][..], <span class='kw-2'>&amp;</span><span class='ident'>vec</span>[..]);
<span class='ident'>vec</span>.<span class='ident'>reverse</span>();
}
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>, <span class='string'>&quot;olleh&quot;</span>);</pre>
</div><h4 id='method.len' class='method'><code>fn <a href='#method.len' class='fnname'>len</a>(&amp;self) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Returns the length of this <code>String</code>, in bytes.</p>
<h1 id='examples-14' class='section-header'><a href='#examples-14'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</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>(&amp;self) -&gt; <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></h4>
<div class='docblock'><p>Returns <code>true</code> if this <code>String</code> has a length of zero.</p>
<p>Returns <code>false</code> otherwise.</p>
<h1 id='examples-15' class='section-header'><a href='#examples-15'>Examples</a></h1>
<p>Basic usage:</p>
<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'>String</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='string'>&#39;a&#39;</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.clear' class='method'><code>fn <a href='#method.clear' class='fnname'>clear</a>(&amp;mut self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
<div class='docblock'><p>Truncates this <code>String</code>, removing all contents.</p>
<p>While this means the <code>String</code> will have a length of zero, it does not
touch its capacity.</p>
<h1 id='examples-16' class='section-header'><a href='#examples-16'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;foo&quot;</span>);
<span class='ident'>s</span>.<span class='ident'>clear</span>();
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>s</span>.<span class='ident'>is_empty</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>0</span>, <span class='ident'>s</span>.<span class='ident'>len</span>());
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='number'>3</span>, <span class='ident'>s</span>.<span class='ident'>capacity</span>());</pre>
</div><h4 id='method.drain' class='method'><code>fn <a href='#method.drain' class='fnname'>drain</a>&lt;R&gt;(&amp;mut self, range: R) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/collections/string/struct.Drain.html' title='collections::string::Drain'>Drain</a> <span class='where'>where R: <a class='trait' href='https://doc.rust-lang.org/nightly/collections/range/trait.RangeArgument.html' title='collections::range::RangeArgument'>RangeArgument</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>&gt;</span></code><div class='since' title='Stable since Rust version 1.6.0'>1.6.0</div></h4>
<div class='docblock'><p>Create a draining iterator that removes the specified range in the string
and yields the removed chars.</p>
<p>Note: The element range is removed even if the iterator is not
consumed until the end.</p>
<h1 id='panics-5' class='section-header'><a href='#panics-5'>Panics</a></h1>
<p>Panics if the starting point or end point do not lie on a <a href="../../std/primitive.char.html"><code>char</code></a>
boundary, or if they&#39;re out of bounds.</p>
<h1 id='examples-17' class='section-header'><a href='#examples-17'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;α is alpha, β is beta&quot;</span>);
<span class='kw'>let</span> <span class='ident'>beta_offset</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>find</span>(<span class='string'>&#39;β&#39;</span>).<span class='ident'>unwrap_or</span>(<span class='ident'>s</span>.<span class='ident'>len</span>());
<span class='comment'>// Remove the range up until the β from the string</span>
<span class='kw'>let</span> <span class='ident'>t</span>: <span class='ident'>String</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>drain</span>(..<span class='ident'>beta_offset</span>).<span class='ident'>collect</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>t</span>, <span class='string'>&quot;α is alpha, &quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>, <span class='string'>&quot;β is beta&quot;</span>);
<span class='comment'>// A full range clears the string</span>
<span class='ident'>s</span>.<span class='ident'>drain</span>(..);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>s</span>, <span class='string'>&quot;&quot;</span>);</pre>
</div><h4 id='method.into_boxed_str' class='method'><code>fn <a href='#method.into_boxed_str' class='fnname'>into_boxed_str</a>(self) -&gt; <a class='struct' href='https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html' title='alloc::boxed::Box'>Box</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;</code><div class='since' title='Stable since Rust version 1.4.0'>1.4.0</div></h4>
<div class='docblock'><p>Converts this <code>String</code> into a <code>Box&lt;str&gt;</code>.</p>
<p>This will drop any excess capacity.</p>
<h1 id='examples-18' class='section-header'><a href='#examples-18'>Examples</a></h1>
<p>Basic usage:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>from</span>(<span class='string'>&quot;hello&quot;</span>);
<span class='kw'>let</span> <span class='ident'>b</span> <span class='op'>=</span> <span class='ident'>s</span>.<span class='ident'>into_boxed_str</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/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a>&lt;<a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a>&gt; for <a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a></code></span><span class='out-of-band'></span></h3>
<div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, __arg_0: &amp;<a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></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'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, __arg_0: &amp;<a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a>) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></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/fmt/trait.Debug.html' title='core::fmt::Debug'>Debug</a> for <a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a></code></span><span class='out-of-band'></span></h3>
<div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, __arg_0: &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>,&nbsp;<a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html' title='core::fmt::Error'>Error</a>&gt;</code></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/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a></code></span><span class='out-of-band'></span></h3>
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a></code></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'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></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/ops/trait.Deref.html' title='core::ops::Deref'>Deref</a> for <a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a></code></span><span class='out-of-band'></span></h3>
<div class='impl-items'><h4 id='associatedtype.Target' class='type'><code>type <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Deref.html#associatedtype.Target' class='type'>Target</a> = <a class='struct' href='https://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a></code></h4>
<div class='docblock'><p>The resulting type after dereferencing</p>
</div><h4 id='method.deref' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Deref.html#tymethod.deref' class='fnname'>deref</a>(&amp;self) -&gt; &amp;<a class='struct' href='https://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a></code></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/trait.DerefMut.html' title='core::ops::DerefMut'>DerefMut</a> for <a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a></code></span><span class='out-of-band'></span></h3>
<div class='impl-items'><h4 id='method.deref_mut' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/trait.DerefMut.html#tymethod.deref_mut' class='fnname'>deref_mut</a>(&amp;mut self) -&gt; &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a></code></h4>
</div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='../../iron/headers/trait.Header.html' title='iron::headers::Header'>Header</a> for <a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a></code></span><span class='out-of-band'></span></h3>
<div class='impl-items'><h4 id='method.header_name' class='method'><code>fn <a href='../../iron/headers/trait.Header.html#tymethod.header_name' class='fnname'>header_name</a>() -&gt; &amp;'static <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
<div class='docblock'><p>Returns the name of the header field this belongs to. <a href="../../iron/headers/trait.Header.html#tymethod.header_name">Read more</a></p>
</div><h4 id='method.parse_header' class='method'><code>fn <a href='../../iron/headers/trait.Header.html#tymethod.parse_header' class='fnname'>parse_header</a>(raw: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&amp;[</a><a class='struct' href='https://doc.rust-lang.org/nightly/collections/vec/struct.Vec.html' title='collections::vec::Vec'>Vec</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u8.html'>u8</a>&gt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>]</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a>&lt;<a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a>,&nbsp;<a class='enum' href='../../iron/error/enum.HttpError.html' title='iron::error::HttpError'>Error</a>&gt;</code></h4>
<div class='docblock'><p>Parse a header from a raw stream of bytes. <a href="../../iron/headers/trait.Header.html#tymethod.parse_header">Read more</a></p>
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='../../iron/headers/trait.HeaderFormat.html' title='iron::headers::HeaderFormat'>HeaderFormat</a> for <a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a></code></span><span class='out-of-band'></span></h3>
<div class='impl-items'><h4 id='method.fmt_header' class='method'><code>fn <a href='../../iron/headers/trait.HeaderFormat.html#tymethod.fmt_header' class='fnname'>fmt_header</a>(&amp;self, f: &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>,&nbsp;<a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html' title='core::fmt::Error'>Error</a>&gt;</code></h4>
<div class='docblock'><p>Format a header to be output into a TcpStream. <a href="../../iron/headers/trait.HeaderFormat.html#tymethod.fmt_header">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.Display.html' title='core::fmt::Display'>Display</a> for <a class='struct' href='../../iron/headers/struct.Referer.html' title='iron::headers::Referer'>Referer</a></code></span><span class='out-of-band'></span></h3>
<div class='impl-items'><h4 id='method.fmt-1' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -&gt; <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>,&nbsp;<a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html' title='core::fmt::Error'>Error</a>&gt;</code></h4>
<div class='docblock'><p>Formats the value using the given formatter.</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>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</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 = "iron";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>