mentat/docs/apis/rust/hyper/header/struct.LastEventId.html
2018-06-22 12:08:32 +01:00

568 lines
No EOL
78 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 `LastEventId` struct in crate `hyper`.">
<meta name="keywords" content="rust, rustlang, rust-lang, LastEventId">
<title>hyper::header::LastEventId - Rust</title>
<link rel="stylesheet" type="text/css" href="../../normalize.css">
<link rel="stylesheet" type="text/css" href="../../rustdoc.css"
id="mainThemeStyle">
<link rel="stylesheet" type="text/css" href="../../dark.css">
<link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle">
<script src="../../storage.js"></script>
</head>
<body class="rustdoc struct">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<div class="sidebar-menu">&#9776;</div>
<p class='location'>Struct LastEventId</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#deref-methods">Methods from Deref&lt;Target=String&gt;</a><div class="sidebar-links"><a href="#method.as_str">as_str</a><a href="#method.capacity">capacity</a><a href="#method.as_bytes">as_bytes</a><a href="#method.len">len</a><a href="#method.is_empty">is_empty</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-PartialEq">PartialEq</a><a href="#impl-Header">Header</a><a href="#impl-Display">Display</a><a href="#impl-Deref">Deref</a><a href="#impl-DerefMut">DerefMut</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a></div></div><p class='location'><a href='../index.html'>hyper</a>::<wbr><a href='index.html'>header</a></p><script>window.sidebarCurrent = {name: 'LastEventId', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div>
</nav>
<div class="theme-picker">
<button id="theme-picker" aria-label="Pick another theme!">
<img src="../../brush.svg" width="18" alt="Pick another theme!">
</button>
<div id="theme-choices"></div>
</div>
<script src="../../theme.js"></script>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content"><h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>hyper</a>::<wbr><a href='index.html'>header</a>::<wbr><a class="struct" href=''>LastEventId</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 class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#25' title='goto source code'>[src]</a></span></h1><div class="docblock type-decl"><pre class='rust struct'>pub struct LastEventId(pub <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>);</pre></div><div class='docblock'><p><code>Last-Event-ID</code> header, defined in
<a href="https://html.spec.whatwg.org/multipage/references.html#refsRFC3864">RFC3864</a></p>
<p>The <code>Last-Event-ID</code> header contains information about
the last event in an http interaction so that it's easier to
track of event state. This is helpful when working
with <a href="http://www.html5rocks.com/en/tutorials/eventsource/basics/">Server-Sent-Events</a>. If the connection were to be dropped, for example, it'd
be useful to let the server know what the last event you
received was.</p>
<p>The spec is a String with the id of the last event, it can be
an empty string which acts a sort of &quot;reset&quot;.</p>
<h1 id="example" class="section-header"><a href="#example">Example</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">LastEventId</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">LastEventId</span>(<span class="string">&quot;1&quot;</span>.<span class="ident">to_owned</span>()));</pre>
</div>
<h2 id='deref-methods' class='small-section-header'>
Methods from <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&lt;Target = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;<a href='#deref-methods' class='anchor'></a>
</h2>
<div class='impl-items'><h4 id='method.as_str' class="method"><span id='as_str.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub 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></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#765-767' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Extracts a string slice containing the entire string.</p>
<h1 id="examples" class="section-header"><a href="#examples">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;foo&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">&quot;foo&quot;</span>, <span class="ident">s</span>.<span class="ident">as_str</span>());</pre>
</div><h4 id='method.as_mut_str' class="method"><span id='as_mut_str.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub 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></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.7.0'>1.7.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#785-787' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Converts a <code>String</code> into a mutable string slice.</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="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;foobar&quot;</span>);
<span class="kw">let</span> <span class="ident">s_mut_str</span> <span class="op">=</span> <span class="ident">s</span>.<span class="ident">as_mut_str</span>();
<span class="ident">s_mut_str</span>.<span class="ident">make_ascii_uppercase</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">&quot;FOOBAR&quot;</span>, <span class="ident">s_mut_str</span>);</pre>
</div><h4 id='method.push_str' class="method"><span id='push_str.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub 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></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#804-806' title='goto source code'>[src]</a></td></tr></tbody></table></span></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"><span id='capacity.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.capacity' class='fnname'>capacity</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#821-823' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Returns this <code>String</code>'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"><span id='reserve.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.reserve' class='fnname'>reserve</a>(&amp;mut self, additional: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#872-874' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Ensures that this <code>String</code>'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="struct.String.html#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 <a href="../../std/primitive.usize.html"><code>usize</code></a>.</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"><span id='reserve_exact.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.reserve_exact' class='fnname'>reserve_exact</a>(&amp;mut self, additional: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#919-921' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Ensures that this <code>String</code>'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.try_reserve' class="method"><span id='try_reserve.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.try_reserve' class='fnname'>try_reserve</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;additional: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="enum" href="https://doc.rust-lang.org/nightly/core/heap/enum.CollectionAllocErr.html" title="enum core::heap::CollectionAllocErr">CollectionAllocErr</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#954-956' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_reserve</code>)</summary><p>new API</p>
</details></div></div><div class='docblock'><p>Tries to reserve capacity for at least <code>additional</code> more elements to be inserted
in the given <code>String</code>. The collection may reserve more space to avoid
frequent reallocations. After calling <code>reserve</code>, capacity will be
greater than or equal to <code>self.len() + additional</code>. Does nothing if
capacity is already sufficient.</p>
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
<p>If the capacity overflows, or the allocator reports a failure, then an error
is returned.</p>
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">try_reserve</span>)]</span>
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">collections</span>::<span class="ident">CollectionAllocErr</span>;
<span class="kw">fn</span> <span class="ident">process_data</span>(<span class="ident">data</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">String</span>, <span class="ident">CollectionAllocErr</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">output</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">new</span>();
<span class="comment">// Pre-reserve the memory, exiting if we can&#39;t</span>
<span class="ident">output</span>.<span class="ident">try_reserve</span>(<span class="ident">data</span>.<span class="ident">len</span>())<span class="question-mark">?</span>;
<span class="comment">// Now we know this can&#39;t OOM in the middle of our complex work</span>
<span class="ident">output</span>.<span class="ident">push_str</span>(<span class="ident">data</span>);
<span class="prelude-val">Ok</span>(<span class="ident">output</span>)
}</pre>
</div><h4 id='method.try_reserve_exact' class="method"><span id='try_reserve_exact.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.try_reserve_exact' class='fnname'>try_reserve_exact</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;additional: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a><br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="enum" href="https://doc.rust-lang.org/nightly/core/heap/enum.CollectionAllocErr.html" title="enum core::heap::CollectionAllocErr">CollectionAllocErr</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#992-994' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_reserve</code>)</summary><p>new API</p>
</details></div></div><div class='docblock'><p>Tries to reserves the minimum capacity for exactly <code>additional</code> more elements to
be inserted in the given <code>String</code>. After calling <code>reserve_exact</code>,
capacity will be greater than or equal to <code>self.len() + additional</code>.
Does nothing if the capacity is already sufficient.</p>
<p>Note that the allocator may give the collection more space than it
requests. Therefore capacity can not be relied upon to be precisely
minimal. Prefer <code>reserve</code> if future insertions are expected.</p>
<h1 id="errors-1" class="section-header"><a href="#errors-1">Errors</a></h1>
<p>If the capacity overflows, or the allocator reports a failure, then an error
is returned.</p>
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">try_reserve</span>)]</span>
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">collections</span>::<span class="ident">CollectionAllocErr</span>;
<span class="kw">fn</span> <span class="ident">process_data</span>(<span class="ident">data</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) <span class="op">-&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">String</span>, <span class="ident">CollectionAllocErr</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">output</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">new</span>();
<span class="comment">// Pre-reserve the memory, exiting if we can&#39;t</span>
<span class="ident">output</span>.<span class="ident">try_reserve</span>(<span class="ident">data</span>.<span class="ident">len</span>())<span class="question-mark">?</span>;
<span class="comment">// Now we know this can&#39;t OOM in the middle of our complex work</span>
<span class="ident">output</span>.<span class="ident">push_str</span>(<span class="ident">data</span>);
<span class="prelude-val">Ok</span>(<span class="ident">output</span>)
}</pre>
</div><h4 id='method.shrink_to_fit' class="method"><span id='shrink_to_fit.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.shrink_to_fit' class='fnname'>shrink_to_fit</a>(&amp;mut self)</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1013-1015' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Shrinks the capacity of this <code>String</code> to match its length.</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="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.shrink_to' class="method"><span id='shrink_to.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.shrink_to' class='fnname'>shrink_to</a>(&amp;mut self, min_capacity: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1041-1043' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>shrink_to</code>)</summary><p>new API</p>
</details></div></div><div class='docblock'><p>Shrinks the capacity of this <code>String</code> with a lower bound.</p>
<p>The capacity will remain at least as large as both the length
and the supplied value.</p>
<p>Panics if the current capacity is smaller than the supplied
minimum capacity.</p>
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">shrink_to</span>)]</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">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</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>);
<span class="ident">s</span>.<span class="ident">shrink_to</span>(<span class="number">0</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">3</span>);</pre>
</div><h4 id='method.push' class="method"><span id='push.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub 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></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1064-1069' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Appends the given <a href="../../std/primitive.char.html"><code>char</code></a> to the end of this <code>String</code>.</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;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"><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;'a [</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></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;'a [</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></h3><code class="content"><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;'a [</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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;'a mut [</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></span></code></div></div><span id='as_bytes.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub 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></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1088-1090' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Returns a byte slice of this <code>String</code>'s contents.</p>
<p>The inverse of this method is <a href="#method.from_utf8"><code>from_utf8</code></a>.</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="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"><span id='truncate.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub 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></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1119-1124' title='goto source code'>[src]</a></td></tr></tbody></table></span></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's current length, this has no
effect.</p>
<p>Note that this method has no effect on the allocated capacity
of the string</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-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">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"><span id='pop.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.pop' class='fnname'>pop</a>(&amp;mut self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.char.html">char</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1147-1154' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Removes the last character from the string buffer and returns it.</p>
<p>Returns <a href="../../std/option/enum.Option.html#variant.None"><code>None</code></a> if this <code>String</code> is empty.</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;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"><span id='remove.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub 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></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1181-1196' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Removes a <a href="../../std/primitive.char.html"><code>char</code></a> 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>'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-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="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.retain' class="method"><span id='retain.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.retain' class='fnname'>retain</a>&lt;F&gt;(&amp;mut self, f: F) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.char.html">char</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.26.0'>1.26.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1215-1245' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Retains only the characters specified by the predicate.</p>
<p>In other words, remove all characters <code>c</code> such that <code>f(c)</code> returns <code>false</code>.
This method operates in place and preserves the order of the retained
characters.</p>
<h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">s</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">from</span>(<span class="string">&quot;f_o_ob_ar&quot;</span>);
<span class="ident">s</span>.<span class="ident">retain</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span> <span class="op">!=</span> <span class="string">&#39;_&#39;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">s</span>, <span class="string">&quot;foobar&quot;</span>);</pre>
</div><h4 id='method.insert' class="method"><span id='insert.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub 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></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1274-1282' title='goto source code'>[src]</a></td></tr></tbody></table></span></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>'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-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">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.insert_str' class="method"><span id='insert_str.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.insert_str' class='fnname'>insert_str</a>(&amp;mut self, idx: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, string: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>)</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.16.0'>1.16.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1323-1329' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Inserts a string slice 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-5" class="section-header"><a href="#panics-5">Panics</a></h1>
<p>Panics if <code>idx</code> is larger than the <code>String</code>'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-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;bar&quot;</span>);
<span class="ident">s</span>.<span class="ident">insert_str</span>(<span class="number">0</span>, <span class="string">&quot;foo&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">&quot;foobar&quot;</span>, <span class="ident">s</span>);</pre>
</div><h4 id='method.as_mut_vec' class="method"><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</span></code></div></div><span id='as_mut_vec.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub 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/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1357-1359' title='goto source code'>[src]</a></td></tr></tbody></table></span></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-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="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"><span id='len.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.len' class='fnname'>len</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1374-1376' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Returns the length of this <code>String</code>, in bytes.</p>
<h1 id="examples-19" class="section-header"><a href="#examples-19">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"><span id='is_empty.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.is_empty' class='fnname'>is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1395-1397' title='goto source code'>[src]</a></td></tr></tbody></table></span></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-20" class="section-header"><a href="#examples-20">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.split_off' class="method"><span id='split_off.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.split_off' class='fnname'>split_off</a>(&amp;mut self, at: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.16.0'>1.16.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1424-1428' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Splits the string into two at the given index.</p>
<p>Returns a newly allocated <code>String</code>. <code>self</code> contains bytes <code>[0, at)</code>, and
the returned <code>String</code> contains bytes <code>[at, len)</code>. <code>at</code> must be on the
boundary of a UTF-8 code point.</p>
<p>Note that the capacity of <code>self</code> does not change.</p>
<h1 id="panics-6" class="section-header"><a href="#panics-6">Panics</a></h1>
<p>Panics if <code>at</code> is not on a <code>UTF-8</code> code point boundary, or if it is beyond the last
code point of the string.</p>
<h1 id="examples-21" class="section-header"><a href="#examples-21">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">hello</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">from</span>(<span class="string">&quot;Hello, World!&quot;</span>);
<span class="kw">let</span> <span class="ident">world</span> <span class="op">=</span> <span class="ident">hello</span>.<span class="ident">split_off</span>(<span class="number">7</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">hello</span>, <span class="string">&quot;Hello, &quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">world</span>, <span class="string">&quot;World!&quot;</span>);</pre>
</div><h4 id='method.clear' class="method"><span id='clear.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.clear' class='fnname'>clear</a>(&amp;mut self)</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1450-1452' title='goto source code'>[src]</a></td></tr></tbody></table></span></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-22" class="section-header"><a href="#examples-22">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"><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.Drain.html" title="struct alloc::string::Drain">Drain</a>&lt;'a&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.Drain.html" title="struct alloc::string::Drain">Drain</a>&lt;'a&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.Drain.html" title="struct alloc::string::Drain">Drain</a>&lt;'a&gt;</span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.char.html">char</a>;</span></code></div></div><span id='drain.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.drain' class='fnname'>drain</a>&lt;R&gt;(&amp;mut self, range: R) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.Drain.html" title="struct alloc::string::Drain">Drain</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/range/trait.RangeBounds.html" title="trait core::ops::range::RangeBounds">RangeBounds</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;,&nbsp;</span></code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.6.0'>1.6.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1485-1518' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Creates 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-7" class="section-header"><a href="#panics-7">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're out of bounds.</p>
<h1 id="examples-23" class="section-header"><a href="#examples-23">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.splice' class="method"><span id='splice.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.splice' class='fnname'>splice</a>&lt;R&gt;(&amp;mut self, range: R, replace_with: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/range/trait.RangeBounds.html" title="trait core::ops::range::RangeBounds">RangeBounds</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;,&nbsp;</span></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#1549-1571' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>splice</code>)</summary><p>recently added</p>
</details></div></div><div class='docblock'><p>Creates a splicing iterator that removes the specified range in the string,
and replaces it with the given string.
The given string doesn't need to be the same length as the range.</p>
<p>Note: Unlike <a href="../../std/vec/struct.Vec.html#method.splice"><code>Vec::splice</code></a>, the replacement happens eagerly, and this
method does not return the removed chars.</p>
<h1 id="panics-8" class="section-header"><a href="#panics-8">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're out of bounds.</p>
<h1 id="examples-24" class="section-header"><a href="#examples-24">Examples</a></h1>
<p>Basic usage:</p>
<pre class="rust rust-example-rendered">
<span class="attribute">#![<span class="ident">feature</span>(<span class="ident">splice</span>)]</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">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">// Replace the range up until the β from the string</span>
<span class="ident">s</span>.<span class="ident">splice</span>(..<span class="ident">beta_offset</span>, <span class="string">&quot;Α is capital alpha; &quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">s</span>, <span class="string">&quot;Α is capital alpha; β is beta&quot;</span>);</pre>
</div></div>
<h2 id='implementations' class='small-section-header'>
Trait Implementations<a href='#implementations' class='anchor'></a>
</h2>
<div id='implementations-list'>
<h3 id='impl-Clone' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a></code><a href='#impl-Clone' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#24' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.clone' class="method"><span id='clone.v' class='invisible'><table class='table-display'><tbody><tr><td><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="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#24' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id='method.clone_from' class="method"><span id='clone_from.v' class='invisible'><table class='table-display'><tbody><tr><td><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: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self)</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/clone.rs.html#117-119' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 id='impl-Debug' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a></code><a href='#impl-Debug' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#24' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><table class='table-display'><tbody><tr><td><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="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#24' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id='impl-PartialEq' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="struct" href="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a></code><a href='#impl-PartialEq' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#24' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.eq' class="method"><span id='eq.v' class='invisible'><table class='table-display'><tbody><tr><td><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="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#24' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id='method.ne' class="method"><span id='ne.v' class='invisible'><table class='table-display'><tbody><tr><td><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="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#24' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 id='impl-Header' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="../../hyper/header/trait.Header.html" title="trait hyper::header::Header">Header</a> for <a class="struct" href="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a></code><a href='#impl-Header' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#27-47' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.header_name' class="method"><span id='header_name.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='../../hyper/header/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></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#29-32' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Returns the name of the header field this belongs to. <a href="../../hyper/header/trait.Header.html#tymethod.header_name">Read more</a></p>
</div><h4 id='method.parse_header' class="method"><span id='parse_header.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='../../hyper/header/trait.Header.html#tymethod.parse_header' class='fnname'>parse_header</a>(raw: &amp;<a class="struct" href="../../hyper/header/struct.Raw.html" title="struct hyper::header::Raw">Raw</a>) -&gt; <a class="type" href="../../hyper/error/type.Result.html" title="type hyper::error::Result">Result</a>&lt;Self&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#35-41' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Parse a header from a raw stream of bytes. <a href="../../hyper/header/trait.Header.html#tymethod.parse_header">Read more</a></p>
</div><h4 id='method.fmt_header' class="method"><span id='fmt_header.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='../../hyper/header/trait.Header.html#tymethod.fmt_header' class='fnname'>fmt_header</a>(&amp;self, f: &amp;mut <a class="struct" href="../../hyper/header/struct.Formatter.html" title="struct hyper::header::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#44-46' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Format a header to outgoing stream. <a href="../../hyper/header/trait.Header.html#tymethod.fmt_header">Read more</a></p>
</div></div><h3 id='impl-Display' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a></code><a href='#impl-Display' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#49-54' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.fmt-1' class="method"><span id='fmt.v-1' class='invisible'><table class='table-display'><tbody><tr><td><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="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/last_event_id.rs.html#51-53' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id='impl-Deref' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> for <a class="struct" href="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a></code><a href='#impl-Deref' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/mod.rs.html#104-111' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Target' class="type"><span id='Target.t' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#associatedtype.Target' class="type">Target</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code></span></h4>
<div class='docblock'><p>The resulting type after dereferencing.</p>
</div><h4 id='method.deref' class="method"><span id='deref.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#tymethod.deref' class='fnname'>deref</a>(&amp;self) -&gt; &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/mod.rs.html#108-110' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Dereferences the value.</p>
</div></div><h3 id='impl-DerefMut' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.DerefMut.html" title="trait core::ops::deref::DerefMut">DerefMut</a> for <a class="struct" href="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a></code><a href='#impl-DerefMut' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/mod.rs.html#113-118' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.deref_mut' class="method"><span id='deref_mut.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/deref/trait.DerefMut.html#tymethod.deref_mut' class='fnname'>deref_mut</a>(&amp;mut self) -&gt; &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/header/common/mod.rs.html#115-117' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Mutably dereferences the value.</p>
</div></div></div>
<h2 id='synthetic-implementations' class='small-section-header'>
Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a>
</h2>
<div id='synthetic-implementations-list'>
<h3 id='impl-Send' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a></code><a href='#impl-Send' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div><h3 id='impl-Sync' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../hyper/header/struct.LastEventId.html" title="struct hyper::header::LastEventId">LastEventId</a></code><a href='#impl-Sync' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div></div></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt><kbd>?</kbd></dt>
<dd>Show this help dialog</dd>
<dt><kbd>S</kbd></dt>
<dd>Focus the search field</dd>
<dt><kbd></kbd></dt>
<dd>Move up in search results</dd>
<dt><kbd></kbd></dt>
<dd>Move down in search results</dd>
<dt><kbd></kbd></dt>
<dd>Switch tab</dd>
<dt><kbd>&#9166;</kbd></dt>
<dd>Go to active search result</dd>
<dt><kbd>+</kbd></dt>
<dd>Expand all sections</dd>
<dt><kbd>-</kbd></dt>
<dd>Collapse all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "hyper";
</script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>