oxipng/doc/bitflags/__core/collections/struct.HashMap.html
2016-05-04 10:41:29 -04:00

615 lines
No EOL
75 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 `HashMap` struct in crate `bitflags`.">
<meta name="keywords" content="rust, rustlang, rust-lang, HashMap">
<title>bitflags::__core::collections::HashMap - Rust</title>
<link rel="stylesheet" type="text/css" href="../../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'><a href='../../index.html'>bitflags</a>::<wbr><a href='../index.html'>__core</a>::<wbr><a href='index.html'>collections</a></p><script>window.sidebarCurrent = {name: 'HashMap', 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'>bitflags</a>::<wbr><a href='../index.html'>__core</a>::<wbr><a href='index.html'>collections</a>::<wbr><a class='struct' href=''>HashMap</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-1694' class='srclink' href='https://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html?gotosrc=1694' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct HashMap&lt;K, V, S = <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.RandomState.html' title='bitflags::__core::collections::hash_map::RandomState'>RandomState</a>&gt; {
// some fields omitted
}</pre><span class="since">1.0.0</span><div class='docblock'><p>A hash map implementation which uses linear probing with Robin
Hood bucket stealing.</p>
<p>The hashes are all keyed by the thread-local random number generator
on creation by default. This means that the ordering of the keys is
randomized, but makes the tables more resistant to
denial-of-service attacks (Hash DoS). This behavior can be
overridden with one of the constructors.</p>
<p>It is required that the keys implement the <code>Eq</code> and <code>Hash</code> traits, although
this can frequently be achieved by using <code>#[derive(PartialEq, Eq, Hash)]</code>.
If you implement these yourself, it is important that the following
property holds:</p>
<pre><code class="language-text">k1 == k2 -&gt; hash(k1) == hash(k2)
</code></pre>
<p>In other words, if two keys are equal, their hashes must be equal.</p>
<p>It is a logic error for a key to be modified in such a way that the key&#39;s
hash, as determined by the <code>Hash</code> trait, or its equality, as determined by
the <code>Eq</code> trait, changes while it is in the map. This is normally only
possible through <code>Cell</code>, <code>RefCell</code>, global state, I/O, or unsafe code.</p>
<p>Relevant papers/articles:</p>
<ol>
<li>Pedro Celis. <a href="https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf">&quot;Robin Hood Hashing&quot;</a></li>
<li>Emmanuel Goossaert. <a href="http://codecapsule.com/2013/11/11/robin-hood-hashing/">&quot;Robin Hood
hashing&quot;</a></li>
<li>Emmanuel Goossaert. <a href="http://codecapsule.com/2013/11/17/robin-hood-hashing-backward-shift-deletion/">&quot;Robin Hood hashing: backward shift
deletion&quot;</a></li>
</ol>
<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'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='comment'>// type inference lets us omit an explicit type signature (which</span>
<span class='comment'>// would be `HashMap&lt;&amp;str, &amp;str&gt;` in this example).</span>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>book_reviews</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='comment'>// review some books.</span>
<span class='ident'>book_reviews</span>.<span class='ident'>insert</span>(<span class='string'>&quot;Adventures of Huckleberry Finn&quot;</span>, <span class='string'>&quot;My favorite book.&quot;</span>);
<span class='ident'>book_reviews</span>.<span class='ident'>insert</span>(<span class='string'>&quot;Grimms&#39; Fairy Tales&quot;</span>, <span class='string'>&quot;Masterpiece.&quot;</span>);
<span class='ident'>book_reviews</span>.<span class='ident'>insert</span>(<span class='string'>&quot;Pride and Prejudice&quot;</span>, <span class='string'>&quot;Very enjoyable.&quot;</span>);
<span class='ident'>book_reviews</span>.<span class='ident'>insert</span>(<span class='string'>&quot;The Adventures of Sherlock Holmes&quot;</span>, <span class='string'>&quot;Eye lyked it alot.&quot;</span>);
<span class='comment'>// check for a specific one.</span>
<span class='kw'>if</span> <span class='op'>!</span><span class='ident'>book_reviews</span>.<span class='ident'>contains_key</span>(<span class='string'>&quot;Les Misérables&quot;</span>) {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;We&#39;ve got {} reviews, but Les Misérables ain&#39;t one.&quot;</span>,
<span class='ident'>book_reviews</span>.<span class='ident'>len</span>());
}
<span class='comment'>// oops, this review has a lot of spelling mistakes, let&#39;s delete it.</span>
<span class='ident'>book_reviews</span>.<span class='ident'>remove</span>(<span class='string'>&quot;The Adventures of Sherlock Holmes&quot;</span>);
<span class='comment'>// look up the values associated with some keys.</span>
<span class='kw'>let</span> <span class='ident'>to_find</span> <span class='op'>=</span> [<span class='string'>&quot;Pride and Prejudice&quot;</span>, <span class='string'>&quot;Alice&#39;s Adventure in Wonderland&quot;</span>];
<span class='kw'>for</span> <span class='ident'>book</span> <span class='kw'>in</span> <span class='kw-2'>&amp;</span><span class='ident'>to_find</span> {
<span class='kw'>match</span> <span class='ident'>book_reviews</span>.<span class='ident'>get</span>(<span class='ident'>book</span>) {
<span class='prelude-val'>Some</span>(<span class='ident'>review</span>) <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}: {}&quot;</span>, <span class='ident'>book</span>, <span class='ident'>review</span>),
<span class='prelude-val'>None</span> <span class='op'>=&gt;</span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{} is unreviewed.&quot;</span>, <span class='ident'>book</span>)
}
}
<span class='comment'>// iterate over everything.</span>
<span class='kw'>for</span> (<span class='ident'>book</span>, <span class='ident'>review</span>) <span class='kw'>in</span> <span class='kw-2'>&amp;</span><span class='ident'>book_reviews</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}: \&quot;{}\&quot;&quot;</span>, <span class='ident'>book</span>, <span class='ident'>review</span>);
}</pre>
<p><code>HashMap</code> also implements an <a href="#method.entry"><code>Entry API</code></a>, which allows
for more complex methods of getting, setting, updating and removing keys and
their values:</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='comment'>// type inference lets us omit an explicit type signature (which</span>
<span class='comment'>// would be `HashMap&lt;&amp;str, u8&gt;` in this example).</span>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>player_stats</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='kw'>fn</span> <span class='ident'>random_stat_buff</span>() <span class='op'>-&gt;</span> <span class='ident'>u8</span> {
<span class='comment'>// could actually return some random value here - let&#39;s just return</span>
<span class='comment'>// some fixed value for now</span>
<span class='number'>42</span>
}
<span class='comment'>// insert a key only if it doesn&#39;t already exist</span>
<span class='ident'>player_stats</span>.<span class='ident'>entry</span>(<span class='string'>&quot;health&quot;</span>).<span class='ident'>or_insert</span>(<span class='number'>100</span>);
<span class='comment'>// insert a key using a function that provides a new value only if it</span>
<span class='comment'>// doesn&#39;t already exist</span>
<span class='ident'>player_stats</span>.<span class='ident'>entry</span>(<span class='string'>&quot;defence&quot;</span>).<span class='ident'>or_insert_with</span>(<span class='ident'>random_stat_buff</span>);
<span class='comment'>// update a key, guarding against the key possibly not being set</span>
<span class='kw'>let</span> <span class='ident'>stat</span> <span class='op'>=</span> <span class='ident'>player_stats</span>.<span class='ident'>entry</span>(<span class='string'>&quot;attack&quot;</span>).<span class='ident'>or_insert</span>(<span class='number'>100</span>);
<span class='op'>*</span><span class='ident'>stat</span> <span class='op'>+=</span> <span class='ident'>random_stat_buff</span>();</pre>
<p>The easiest way to use <code>HashMap</code> with a custom type as key is to derive <code>Eq</code> and <code>Hash</code>.
We must also derive <code>PartialEq</code>.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='attribute'>#[<span class='ident'>derive</span>(<span class='ident'>Hash</span>, <span class='ident'>Eq</span>, <span class='ident'>PartialEq</span>, <span class='ident'>Debug</span>)]</span>
<span class='kw'>struct</span> <span class='ident'>Viking</span> {
<span class='ident'>name</span>: <span class='ident'>String</span>,
<span class='ident'>country</span>: <span class='ident'>String</span>,
}
<span class='kw'>impl</span> <span class='ident'>Viking</span> {
<span class='doccomment'>/// Create a new Viking.</span>
<span class='kw'>fn</span> <span class='ident'>new</span>(<span class='ident'>name</span>: <span class='kw-2'>&amp;</span><span class='ident'>str</span>, <span class='ident'>country</span>: <span class='kw-2'>&amp;</span><span class='ident'>str</span>) <span class='op'>-&gt;</span> <span class='ident'>Viking</span> {
<span class='ident'>Viking</span> { <span class='ident'>name</span>: <span class='ident'>name</span>.<span class='ident'>to_string</span>(), <span class='ident'>country</span>: <span class='ident'>country</span>.<span class='ident'>to_string</span>() }
}
}
<span class='comment'>// Use a HashMap to store the vikings&#39; health points.</span>
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>vikings</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>vikings</span>.<span class='ident'>insert</span>(<span class='ident'>Viking</span>::<span class='ident'>new</span>(<span class='string'>&quot;Einar&quot;</span>, <span class='string'>&quot;Norway&quot;</span>), <span class='number'>25</span>);
<span class='ident'>vikings</span>.<span class='ident'>insert</span>(<span class='ident'>Viking</span>::<span class='ident'>new</span>(<span class='string'>&quot;Olaf&quot;</span>, <span class='string'>&quot;Denmark&quot;</span>), <span class='number'>24</span>);
<span class='ident'>vikings</span>.<span class='ident'>insert</span>(<span class='ident'>Viking</span>::<span class='ident'>new</span>(<span class='string'>&quot;Harald&quot;</span>, <span class='string'>&quot;Iceland&quot;</span>), <span class='number'>12</span>);
<span class='comment'>// Use derived implementation to print the status of the vikings.</span>
<span class='kw'>for</span> (<span class='ident'>viking</span>, <span class='ident'>health</span>) <span class='kw'>in</span> <span class='kw-2'>&amp;</span><span class='ident'>vikings</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{:?} has {} hp&quot;</span>, <span class='ident'>viking</span>, <span class='ident'>health</span>);
}</pre>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><code>impl&lt;K, V&gt; <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.RandomState.html' title='bitflags::__core::collections::hash_map::RandomState'>RandomState</a>&gt; <span class='where'>where K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a></span></code></h3><div class='impl-items'><h4 id='method.new' class='method'><code>fn <a href='#method.new' class='fnname'>new</a>() -&gt; <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.RandomState.html' title='bitflags::__core::collections::hash_map::RandomState'>RandomState</a>&gt;</code></h4>
<div class='docblock'><p>Creates an empty HashMap.</p>
<h1 id='examples-1' class='section-header'><a href='#examples-1'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span>, <span class='ident'>isize</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();</pre>
</div><h4 id='method.with_capacity' class='method'><code>fn <a href='#method.with_capacity' class='fnname'>with_capacity</a>(capacity: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>) -&gt; <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.RandomState.html' title='bitflags::__core::collections::hash_map::RandomState'>RandomState</a>&gt;</code></h4>
<div class='docblock'><p>Creates an empty hash map with the given initial capacity.</p>
<h1 id='examples-2' class='section-header'><a href='#examples-2'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span>, <span class='ident'>isize</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>with_capacity</span>(<span class='number'>10</span>);</pre>
</div></div><h3 class='impl'><code>impl&lt;K, V, S&gt; <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a>, K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a></span></code></h3><div class='impl-items'><h4 id='method.with_hasher' class='method'><code>fn <a href='#method.with_hasher' class='fnname'>with_hasher</a>(hash_builder: S) -&gt; <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt;</code><span class="since">1.7.0</span></h4>
<div class='docblock'><p>Creates an empty hashmap which will use the given hash builder to hash
keys.</p>
<p>The created map has the default initial capacity.</p>
<p>Warning: <code>hash_builder</code> is normally randomly generated, and
is designed to allow HashMaps to be resistant to attacks that
cause many collisions and very poor performance. Setting it
manually using this function can expose a DoS attack vector.</p>
<h1 id='examples-3' class='section-header'><a href='#examples-3'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>hash_map</span>::<span class='ident'>RandomState</span>;
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>RandomState</span>::<span class='ident'>new</span>();
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>with_hasher</span>(<span class='ident'>s</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='number'>2</span>);</pre>
</div><h4 id='method.with_capacity_and_hasher' class='method'><code>fn <a href='#method.with_capacity_and_hasher' class='fnname'>with_capacity_and_hasher</a>(capacity: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>, hash_builder: S) -&gt; <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt;</code><span class="since">1.7.0</span></h4>
<div class='docblock'><p>Creates an empty HashMap with space for at least <code>capacity</code>
elements, using <code>hasher</code> to hash the keys.</p>
<p>Warning: <code>hasher</code> is normally randomly generated, and
is designed to allow HashMaps to be resistant to attacks that
cause many collisions and very poor performance. Setting it
manually using this function can expose a DoS attack vector.</p>
<h1 id='examples-4' class='section-header'><a href='#examples-4'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>hash_map</span>::<span class='ident'>RandomState</span>;
<span class='kw'>let</span> <span class='ident'>s</span> <span class='op'>=</span> <span class='ident'>RandomState</span>::<span class='ident'>new</span>();
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>with_capacity_and_hasher</span>(<span class='number'>10</span>, <span class='ident'>s</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='number'>2</span>);</pre>
</div><h4 id='method.hasher' class='method'><code>fn <a href='#method.hasher' class='fnname'>hasher</a>(&amp;self) -&gt; &amp;S</code><span class="since">1.9.0</span></h4>
<div class='docblock'><p>Returns a reference to the map&#39;s hasher.</p>
</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/bitflags/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>Returns the number of elements the map can hold without reallocating.</p>
<p>This number is a lower bound; the <code>HashMap&lt;K, V&gt;</code> might be able to hold
more, but is guaranteed to be able to hold at least this many.</p>
<h1 id='examples-5' class='section-header'><a href='#examples-5'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='ident'>map</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='ident'>isize</span>, <span class='ident'>isize</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>with_capacity</span>(<span class='number'>100</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>capacity</span>() <span class='op'>&gt;=</span> <span class='number'>100</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/bitflags/primitive.usize.html'>usize</a>)</code></h4>
<div class='docblock'><p>Reserves capacity for at least <code>additional</code> more elements to be inserted
in the <code>HashMap</code>. The collection may reserve more space to avoid
frequent reallocations.</p>
<h1 id='panics' class='section-header'><a href='#panics'>Panics</a></h1>
<p>Panics if the new allocation size overflows <code>usize</code>.</p>
<h1 id='examples-6' class='section-header'><a href='#examples-6'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='kw-2'>&amp;</span><span class='ident'>str</span>, <span class='ident'>isize</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>map</span>.<span class='ident'>reserve</span>(<span class='number'>10</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></h4>
<div class='docblock'><p>Shrinks the capacity of the map as much as possible. It will drop
down as much as possible while maintaining the internal rules
and possibly leaving some space in accordance with the resize policy.</p>
<h1 id='examples-7' class='section-header'><a href='#examples-7'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span>: <span class='ident'>HashMap</span><span class='op'>&lt;</span><span class='ident'>isize</span>, <span class='ident'>isize</span><span class='op'>&gt;</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>with_capacity</span>(<span class='number'>100</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='number'>2</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='number'>3</span>, <span class='number'>4</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>capacity</span>() <span class='op'>&gt;=</span> <span class='number'>100</span>);
<span class='ident'>map</span>.<span class='ident'>shrink_to_fit</span>();
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>capacity</span>() <span class='op'>&gt;=</span> <span class='number'>2</span>);</pre>
</div><h4 id='method.keys' class='method'><code>fn <a href='#method.keys' class='fnname'>keys</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.Keys.html' title='bitflags::__core::collections::hash_map::Keys'>Keys</a>&lt;K, V&gt;</code></h4>
<div class='docblock'><p>An iterator visiting all keys in arbitrary order.
Iterator element type is <code>&amp;&#39;a K</code>.</p>
<h1 id='examples-8' class='section-header'><a href='#examples-8'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;a&quot;</span>, <span class='number'>1</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;b&quot;</span>, <span class='number'>2</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;c&quot;</span>, <span class='number'>3</span>);
<span class='kw'>for</span> <span class='ident'>key</span> <span class='kw'>in</span> <span class='ident'>map</span>.<span class='ident'>keys</span>() {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>key</span>);
}</pre>
</div><h4 id='method.values' class='method'><code>fn <a href='#method.values' class='fnname'>values</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.Values.html' title='bitflags::__core::collections::hash_map::Values'>Values</a>&lt;K, V&gt;</code></h4>
<div class='docblock'><p>An iterator visiting all values in arbitrary order.
Iterator element type is <code>&amp;&#39;a V</code>.</p>
<h1 id='examples-9' class='section-header'><a href='#examples-9'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;a&quot;</span>, <span class='number'>1</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;b&quot;</span>, <span class='number'>2</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;c&quot;</span>, <span class='number'>3</span>);
<span class='kw'>for</span> <span class='ident'>val</span> <span class='kw'>in</span> <span class='ident'>map</span>.<span class='ident'>values</span>() {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>val</span>);
}</pre>
</div><h4 id='method.values_mut' class='method'><code>fn <a href='#method.values_mut' class='fnname'>values_mut</a>(&amp;'a mut self) -&gt; <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.ValuesMut.html' title='bitflags::__core::collections::hash_map::ValuesMut'>ValuesMut</a>&lt;'a, K, V&gt;</code></h4>
<div class='stability'><em class='stab unstable'>Unstable (<code>map_values_mut</code>)<p>: recently added</p>
</em></div><div class='docblock'><p>An iterator visiting all values mutably in arbitrary order.
Iterator element type is <code>&amp;&#39;a mut V</code>.</p>
<h1 id='examples-10' class='section-header'><a href='#examples-10'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;a&quot;</span>, <span class='number'>1</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;b&quot;</span>, <span class='number'>2</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;c&quot;</span>, <span class='number'>3</span>);
<span class='kw'>for</span> <span class='ident'>val</span> <span class='kw'>in</span> <span class='ident'>map</span>.<span class='ident'>values_mut</span>() {
<span class='op'>*</span><span class='ident'>val</span> <span class='op'>=</span> <span class='op'>*</span><span class='ident'>val</span> <span class='op'>+</span> <span class='number'>10</span>;
}
<span class='kw'>for</span> <span class='ident'>val</span> <span class='kw'>in</span> <span class='ident'>map</span>.<span class='ident'>values</span>() {
<span class='macro'>print</span><span class='macro'>!</span>(<span class='string'>&quot;{}&quot;</span>, <span class='ident'>val</span>);
}</pre>
</div><h4 id='method.iter' class='method'><code>fn <a href='#method.iter' class='fnname'>iter</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.Iter.html' title='bitflags::__core::collections::hash_map::Iter'>Iter</a>&lt;K, V&gt;</code></h4>
<div class='docblock'><p>An iterator visiting all key-value pairs in arbitrary order.
Iterator element type is <code>(&amp;&#39;a K, &amp;&#39;a V)</code>.</p>
<h1 id='examples-11' class='section-header'><a href='#examples-11'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;a&quot;</span>, <span class='number'>1</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;b&quot;</span>, <span class='number'>2</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;c&quot;</span>, <span class='number'>3</span>);
<span class='kw'>for</span> (<span class='ident'>key</span>, <span class='ident'>val</span>) <span class='kw'>in</span> <span class='ident'>map</span>.<span class='ident'>iter</span>() {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;key: {} val: {}&quot;</span>, <span class='ident'>key</span>, <span class='ident'>val</span>);
}</pre>
</div><h4 id='method.iter_mut' class='method'><code>fn <a href='#method.iter_mut' class='fnname'>iter_mut</a>(&amp;mut self) -&gt; <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.IterMut.html' title='bitflags::__core::collections::hash_map::IterMut'>IterMut</a>&lt;K, V&gt;</code></h4>
<div class='docblock'><p>An iterator visiting all key-value pairs in arbitrary order,
with mutable references to the values.
Iterator element type is <code>(&amp;&#39;a K, &amp;&#39;a mut V)</code>.</p>
<h1 id='examples-12' class='section-header'><a href='#examples-12'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;a&quot;</span>, <span class='number'>1</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;b&quot;</span>, <span class='number'>2</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;c&quot;</span>, <span class='number'>3</span>);
<span class='comment'>// Update all values</span>
<span class='kw'>for</span> (_, <span class='ident'>val</span>) <span class='kw'>in</span> <span class='ident'>map</span>.<span class='ident'>iter_mut</span>() {
<span class='op'>*</span><span class='ident'>val</span> <span class='op'>*=</span> <span class='number'>2</span>;
}
<span class='kw'>for</span> (<span class='ident'>key</span>, <span class='ident'>val</span>) <span class='kw'>in</span> <span class='kw-2'>&amp;</span><span class='ident'>map</span> {
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>&quot;key: {} val: {}&quot;</span>, <span class='ident'>key</span>, <span class='ident'>val</span>);
}</pre>
</div><h4 id='method.entry' class='method'><code>fn <a href='#method.entry' class='fnname'>entry</a>(&amp;mut self, key: K) -&gt; <a class='enum' href='../../../bitflags/__core/collections/hash_map/enum.Entry.html' title='bitflags::__core::collections::hash_map::Entry'>Entry</a>&lt;K, V&gt;</code></h4>
<div class='docblock'><p>Gets the given key&#39;s corresponding entry in the map for in-place manipulation.</p>
<h1 id='examples-13' class='section-header'><a href='#examples-13'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>letters</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='kw'>for</span> <span class='ident'>ch</span> <span class='kw'>in</span> <span class='string'>&quot;a short treatise on fungi&quot;</span>.<span class='ident'>chars</span>() {
<span class='kw'>let</span> <span class='ident'>counter</span> <span class='op'>=</span> <span class='ident'>letters</span>.<span class='ident'>entry</span>(<span class='ident'>ch</span>).<span class='ident'>or_insert</span>(<span class='number'>0</span>);
<span class='op'>*</span><span class='ident'>counter</span> <span class='op'>+=</span> <span class='number'>1</span>;
}
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>letters</span>[<span class='kw-2'>&amp;</span><span class='string'>&#39;s&#39;</span>], <span class='number'>2</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>letters</span>[<span class='kw-2'>&amp;</span><span class='string'>&#39;t&#39;</span>], <span class='number'>3</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>letters</span>[<span class='kw-2'>&amp;</span><span class='string'>&#39;u&#39;</span>], <span class='number'>1</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>letters</span>.<span class='ident'>get</span>(<span class='kw-2'>&amp;</span><span class='string'>&#39;y&#39;</span>), <span class='prelude-val'>None</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/bitflags/primitive.usize.html'>usize</a></code></h4>
<div class='docblock'><p>Returns the number of elements in the map.</p>
<h1 id='examples-14' class='section-header'><a href='#examples-14'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>a</span>.<span class='ident'>len</span>(), <span class='number'>0</span>);
<span class='ident'>a</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='string'>&quot;a&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'>1</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/bitflags/primitive.bool.html'>bool</a></code></h4>
<div class='docblock'><p>Returns true if the map contains no elements.</p>
<h1 id='examples-15' class='section-header'><a href='#examples-15'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>a</span>.<span class='ident'>is_empty</span>());
<span class='ident'>a</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='string'>&quot;a&quot;</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>a</span>.<span class='ident'>is_empty</span>());</pre>
</div><h4 id='method.drain' class='method'><code>fn <a href='#method.drain' class='fnname'>drain</a>(&amp;mut self) -&gt; <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.Drain.html' title='bitflags::__core::collections::hash_map::Drain'>Drain</a>&lt;K, V&gt;</code><span class="since">1.6.0</span></h4>
<div class='docblock'><p>Clears the map, returning all key-value pairs as an iterator. Keeps the
allocated memory for reuse.</p>
<h1 id='examples-16' class='section-header'><a href='#examples-16'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>a</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='string'>&quot;a&quot;</span>);
<span class='ident'>a</span>.<span class='ident'>insert</span>(<span class='number'>2</span>, <span class='string'>&quot;b&quot;</span>);
<span class='kw'>for</span> (<span class='ident'>k</span>, <span class='ident'>v</span>) <span class='kw'>in</span> <span class='ident'>a</span>.<span class='ident'>drain</span>().<span class='ident'>take</span>(<span class='number'>1</span>) {
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>k</span> <span class='op'>==</span> <span class='number'>1</span> <span class='op'>||</span> <span class='ident'>k</span> <span class='op'>==</span> <span class='number'>2</span>);
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>v</span> <span class='op'>==</span> <span class='string'>&quot;a&quot;</span> <span class='op'>||</span> <span class='ident'>v</span> <span class='op'>==</span> <span class='string'>&quot;b&quot;</span>);
}
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>a</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></h4>
<div class='docblock'><p>Clears the map, removing all key-value pairs. Keeps the allocated memory
for reuse.</p>
<h1 id='examples-17' class='section-header'><a href='#examples-17'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>a</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>a</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='string'>&quot;a&quot;</span>);
<span class='ident'>a</span>.<span class='ident'>clear</span>();
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>a</span>.<span class='ident'>is_empty</span>());</pre>
</div><h4 id='method.get' class='method'><code>fn <a href='#method.get' class='fnname'>get</a>&lt;Q&gt;(&amp;self, k: &amp;Q) -&gt; <a class='enum' href='../../../bitflags/__core/option/enum.Option.html' title='bitflags::__core::option::Option'>Option</a>&lt;&amp;V&gt; <span class='where'>where Q: <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a> + <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + ?<a class='trait' href='../../../bitflags/__core/marker/trait.Sized.html' title='bitflags::__core::marker::Sized'>Sized</a>, K: <a class='trait' href='../../../bitflags/__core/borrow/trait.Borrow.html' title='bitflags::__core::borrow::Borrow'>Borrow</a>&lt;Q&gt;</span></code></h4>
<div class='docblock'><p>Returns a reference to the value corresponding to the key.</p>
<p>The key may be any borrowed form of the map&#39;s key type, but
<code>Hash</code> and <code>Eq</code> on the borrowed form <em>must</em> match those for
the key type.</p>
<h1 id='examples-18' class='section-header'><a href='#examples-18'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='string'>&quot;a&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>get</span>(<span class='kw-2'>&amp;</span><span class='number'>1</span>), <span class='prelude-val'>Some</span>(<span class='kw-2'>&amp;</span><span class='string'>&quot;a&quot;</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>get</span>(<span class='kw-2'>&amp;</span><span class='number'>2</span>), <span class='prelude-val'>None</span>);</pre>
</div><h4 id='method.contains_key' class='method'><code>fn <a href='#method.contains_key' class='fnname'>contains_key</a>&lt;Q&gt;(&amp;self, k: &amp;Q) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a> <span class='where'>where Q: <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a> + <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + ?<a class='trait' href='../../../bitflags/__core/marker/trait.Sized.html' title='bitflags::__core::marker::Sized'>Sized</a>, K: <a class='trait' href='../../../bitflags/__core/borrow/trait.Borrow.html' title='bitflags::__core::borrow::Borrow'>Borrow</a>&lt;Q&gt;</span></code></h4>
<div class='docblock'><p>Returns true if the map contains a value for the specified key.</p>
<p>The key may be any borrowed form of the map&#39;s key type, but
<code>Hash</code> and <code>Eq</code> on the borrowed form <em>must</em> match those for
the key type.</p>
<h1 id='examples-19' class='section-header'><a href='#examples-19'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='string'>&quot;a&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>contains_key</span>(<span class='kw-2'>&amp;</span><span class='number'>1</span>), <span class='boolval'>true</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>contains_key</span>(<span class='kw-2'>&amp;</span><span class='number'>2</span>), <span class='boolval'>false</span>);</pre>
</div><h4 id='method.get_mut' class='method'><code>fn <a href='#method.get_mut' class='fnname'>get_mut</a>&lt;Q&gt;(&amp;mut self, k: &amp;Q) -&gt; <a class='enum' href='../../../bitflags/__core/option/enum.Option.html' title='bitflags::__core::option::Option'>Option</a>&lt;&amp;mut V&gt; <span class='where'>where Q: <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a> + <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + ?<a class='trait' href='../../../bitflags/__core/marker/trait.Sized.html' title='bitflags::__core::marker::Sized'>Sized</a>, K: <a class='trait' href='../../../bitflags/__core/borrow/trait.Borrow.html' title='bitflags::__core::borrow::Borrow'>Borrow</a>&lt;Q&gt;</span></code></h4>
<div class='docblock'><p>Returns a mutable reference to the value corresponding to the key.</p>
<p>The key may be any borrowed form of the map&#39;s key type, but
<code>Hash</code> and <code>Eq</code> on the borrowed form <em>must</em> match those for
the key type.</p>
<h1 id='examples-20' class='section-header'><a href='#examples-20'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='string'>&quot;a&quot;</span>);
<span class='kw'>if</span> <span class='kw'>let</span> <span class='prelude-val'>Some</span>(<span class='ident'>x</span>) <span class='op'>=</span> <span class='ident'>map</span>.<span class='ident'>get_mut</span>(<span class='kw-2'>&amp;</span><span class='number'>1</span>) {
<span class='op'>*</span><span class='ident'>x</span> <span class='op'>=</span> <span class='string'>&quot;b&quot;</span>;
}
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>map</span>[<span class='kw-2'>&amp;</span><span class='number'>1</span>], <span class='string'>&quot;b&quot;</span>);</pre>
</div><h4 id='method.insert' class='method'><code>fn <a href='#method.insert' class='fnname'>insert</a>(&amp;mut self, k: K, v: V) -&gt; <a class='enum' href='../../../bitflags/__core/option/enum.Option.html' title='bitflags::__core::option::Option'>Option</a>&lt;V&gt;</code></h4>
<div class='docblock'><p>Inserts a key-value pair into the map.</p>
<p>If the map did not have this key present, <code>None</code> is returned.</p>
<p>If the map did have this key present, the value is updated, and the old
value is returned. The key is not updated, though; this matters for
types that can be <code>==</code> without being identical. See the <a href="index.html#insert-and-complex-keys">module-level
documentation</a> for more.</p>
<h1 id='examples-21' class='section-header'><a href='#examples-21'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='number'>37</span>, <span class='string'>&quot;a&quot;</span>), <span class='prelude-val'>None</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>is_empty</span>(), <span class='boolval'>false</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='number'>37</span>, <span class='string'>&quot;b&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='number'>37</span>, <span class='string'>&quot;c&quot;</span>), <span class='prelude-val'>Some</span>(<span class='string'>&quot;b&quot;</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>map</span>[<span class='kw-2'>&amp;</span><span class='number'>37</span>], <span class='string'>&quot;c&quot;</span>);</pre>
</div><h4 id='method.remove' class='method'><code>fn <a href='#method.remove' class='fnname'>remove</a>&lt;Q&gt;(&amp;mut self, k: &amp;Q) -&gt; <a class='enum' href='../../../bitflags/__core/option/enum.Option.html' title='bitflags::__core::option::Option'>Option</a>&lt;V&gt; <span class='where'>where Q: <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a> + <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + ?<a class='trait' href='../../../bitflags/__core/marker/trait.Sized.html' title='bitflags::__core::marker::Sized'>Sized</a>, K: <a class='trait' href='../../../bitflags/__core/borrow/trait.Borrow.html' title='bitflags::__core::borrow::Borrow'>Borrow</a>&lt;Q&gt;</span></code></h4>
<div class='docblock'><p>Removes a key from the map, returning the value at the key if the key
was previously in the map.</p>
<p>The key may be any borrowed form of the map&#39;s key type, but
<code>Hash</code> and <code>Eq</code> on the borrowed form <em>must</em> match those for
the key type.</p>
<h1 id='examples-22' class='section-header'><a href='#examples-22'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='number'>1</span>, <span class='string'>&quot;a&quot;</span>);
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>remove</span>(<span class='kw-2'>&amp;</span><span class='number'>1</span>), <span class='prelude-val'>Some</span>(<span class='string'>&quot;a&quot;</span>));
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>map</span>.<span class='ident'>remove</span>(<span class='kw-2'>&amp;</span><span class='number'>1</span>), <span class='prelude-val'>None</span>);</pre>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><code>impl&lt;K, V, S&gt; <a class='trait' href='../../../bitflags/__core/cmp/trait.PartialEq.html' title='bitflags::__core::cmp::PartialEq'>PartialEq</a>&lt;<a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt;&gt; for <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where V: <a class='trait' href='../../../bitflags/__core/cmp/trait.PartialEq.html' title='bitflags::__core::cmp::PartialEq'>PartialEq</a>&lt;V&gt;, K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a>, S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a></span></code></h3><div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&amp;self, other: &amp;<a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt;) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
<h4 id='method.ne' class='method'><code>fn <a href='../../../bitflags/__core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&amp;self, other: &amp;Rhs) -&gt; <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.bool.html'>bool</a></code></h4>
</div><h3 class='impl'><code>impl&lt;K, V, S&gt; <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> for <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a>, S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a>, V: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a></span></code></h3><div class='impl-items'></div><h3 class='impl'><code>impl&lt;K, V, S&gt; <a class='trait' href='../../../bitflags/__core/fmt/trait.Debug.html' title='bitflags::__core::fmt::Debug'>Debug</a> for <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a>, V: <a class='trait' href='../../../bitflags/__core/fmt/trait.Debug.html' title='bitflags::__core::fmt::Debug'>Debug</a>, K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a> + <a class='trait' href='../../../bitflags/__core/fmt/trait.Debug.html' title='bitflags::__core::fmt::Debug'>Debug</a></span></code></h3><div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='../../../bitflags/__core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class='struct' href='../../../bitflags/__core/fmt/struct.Formatter.html' title='bitflags::__core::fmt::Formatter'>Formatter</a>) -&gt; <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>()</a>, <a class='struct' href='../../../bitflags/__core/fmt/struct.Error.html' title='bitflags::__core::fmt::Error'>Error</a>&gt;</code></h4>
</div><h3 class='impl'><code>impl&lt;K, V, S&gt; <a class='trait' href='../../../bitflags/__core/default/trait.Default.html' title='bitflags::__core::default::Default'>Default</a> for <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a>, S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a> + <a class='trait' href='../../../bitflags/__core/default/trait.Default.html' title='bitflags::__core::default::Default'>Default</a></span></code></h3><div class='impl-items'><h4 id='method.default' class='method'><code>fn <a href='../../../bitflags/__core/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -&gt; <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt;</code></h4>
</div><h3 class='impl'><code>impl&lt;'a, K, Q, V, S&gt; <a class='trait' href='../../../bitflags/__core/ops/trait.Index.html' title='bitflags::__core::ops::Index'>Index</a>&lt;&amp;'a Q&gt; for <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where Q: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a> + ?<a class='trait' href='../../../bitflags/__core/marker/trait.Sized.html' title='bitflags::__core::marker::Sized'>Sized</a>, K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a> + <a class='trait' href='../../../bitflags/__core/borrow/trait.Borrow.html' title='bitflags::__core::borrow::Borrow'>Borrow</a>&lt;Q&gt;, S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a></span></code></h3><div class='impl-items'><h4 id='associatedtype.Output' class='type'><code>type <a href='../../../bitflags/__core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = V</code></h4>
<h4 id='method.index' class='method'><code>fn <a href='../../../bitflags/__core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&amp;self, index: &amp;Q) -&gt; &amp;V</code></h4>
</div><h3 class='impl'><code>impl&lt;'a, K, V, S&gt; <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a> for &amp;'a <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a>, K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a></span></code></h3><div class='impl-items'><h4 id='associatedtype.Item' class='type'><code>type <a href='../../../bitflags/__core/iter/trait.IntoIterator.html#associatedtype.Item' class='type'>Item</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a>&amp;'a K, &amp;'a V<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a></code></h4>
<h4 id='associatedtype.IntoIter' class='type'><code>type <a href='../../../bitflags/__core/iter/trait.IntoIterator.html#associatedtype.IntoIter' class='type'>IntoIter</a> = <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.Iter.html' title='bitflags::__core::collections::hash_map::Iter'>Iter</a>&lt;'a, K, V&gt;</code></h4>
<h4 id='method.into_iter' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.IntoIterator.html#tymethod.into_iter' class='fnname'>into_iter</a>(self) -&gt; <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.Iter.html' title='bitflags::__core::collections::hash_map::Iter'>Iter</a>&lt;'a, K, V&gt;</code></h4>
</div><h3 class='impl'><code>impl&lt;'a, K, V, S&gt; <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a> for &amp;'a mut <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a>, S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a></span></code></h3><div class='impl-items'><h4 id='associatedtype.Item-1' class='type'><code>type <a href='../../../bitflags/__core/iter/trait.IntoIterator.html#associatedtype.Item' class='type'>Item</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a>&amp;'a K, &amp;'a mut V<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a></code></h4>
<h4 id='associatedtype.IntoIter-1' class='type'><code>type <a href='../../../bitflags/__core/iter/trait.IntoIterator.html#associatedtype.IntoIter' class='type'>IntoIter</a> = <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.IterMut.html' title='bitflags::__core::collections::hash_map::IterMut'>IterMut</a>&lt;'a, K, V&gt;</code></h4>
<h4 id='method.into_iter-1' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.IntoIterator.html#tymethod.into_iter' class='fnname'>into_iter</a>(self) -&gt; <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.IterMut.html' title='bitflags::__core::collections::hash_map::IterMut'>IterMut</a>&lt;'a, K, V&gt;</code></h4>
</div><h3 class='impl'><code>impl&lt;K, V, S&gt; <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a> for <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a>, K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a></span></code></h3><div class='impl-items'><h4 id='associatedtype.Item-2' class='type'><code>type <a href='../../../bitflags/__core/iter/trait.IntoIterator.html#associatedtype.Item' class='type'>Item</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a>K, V<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a></code></h4>
<h4 id='associatedtype.IntoIter-2' class='type'><code>type <a href='../../../bitflags/__core/iter/trait.IntoIterator.html#associatedtype.IntoIter' class='type'>IntoIter</a> = <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.IntoIter.html' title='bitflags::__core::collections::hash_map::IntoIter'>IntoIter</a>&lt;K, V&gt;</code></h4>
<h4 id='method.into_iter-2' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.IntoIterator.html#tymethod.into_iter' class='fnname'>into_iter</a>(self) -&gt; <a class='struct' href='../../../bitflags/__core/collections/hash_map/struct.IntoIter.html' title='bitflags::__core::collections::hash_map::IntoIter'>IntoIter</a>&lt;K, V&gt;</code></h4>
<div class='docblock'><p>Creates a consuming iterator, that is, one that moves each key-value
pair out of the map in arbitrary order. The map cannot be used after
calling this.</p>
<h1 id='examples-23' class='section-header'><a href='#examples-23'>Examples</a></h1>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>collections</span>::<span class='ident'>HashMap</span>;
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>map</span> <span class='op'>=</span> <span class='ident'>HashMap</span>::<span class='ident'>new</span>();
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;a&quot;</span>, <span class='number'>1</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;b&quot;</span>, <span class='number'>2</span>);
<span class='ident'>map</span>.<span class='ident'>insert</span>(<span class='string'>&quot;c&quot;</span>, <span class='number'>3</span>);
<span class='comment'>// Not possible with .iter()</span>
<span class='kw'>let</span> <span class='ident'>vec</span>: <span class='ident'>Vec</span><span class='op'>&lt;</span>(<span class='kw-2'>&amp;</span><span class='ident'>str</span>, <span class='ident'>isize</span>)<span class='op'>&gt;</span> <span class='op'>=</span> <span class='ident'>map</span>.<span class='ident'>into_iter</span>().<span class='ident'>collect</span>();</pre>
</div></div><h3 class='impl'><code>impl&lt;K, V, S&gt; <a class='trait' href='../../../bitflags/__core/iter/trait.FromIterator.html' title='bitflags::__core::iter::FromIterator'>FromIterator</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a>K, V<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a>&gt; for <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a> + <a class='trait' href='../../../bitflags/__core/default/trait.Default.html' title='bitflags::__core::default::Default'>Default</a>, K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a></span></code></h3><div class='impl-items'><h4 id='method.from_iter' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.FromIterator.html#tymethod.from_iter' class='fnname'>from_iter</a>&lt;T&gt;(iter: T) -&gt; <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where T: <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a>&lt;Item=<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a>K, V<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a>&gt;</span></code></h4>
</div><h3 class='impl'><code>impl&lt;K, V, S&gt; <a class='trait' href='../../../bitflags/__core/iter/trait.Extend.html' title='bitflags::__core::iter::Extend'>Extend</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a>K, V<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a>&gt; for <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a>, K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a></span></code></h3><div class='impl-items'><h4 id='method.extend' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.Extend.html#tymethod.extend' class='fnname'>extend</a>&lt;T&gt;(&amp;mut self, iter: T) <span class='where'>where T: <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a>&lt;Item=<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a>K, V<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a>&gt;</span></code></h4>
</div><h3 class='impl'><code>impl&lt;'a, K, V, S&gt; <a class='trait' href='../../../bitflags/__core/iter/trait.Extend.html' title='bitflags::__core::iter::Extend'>Extend</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a>&amp;'a K, &amp;'a V<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a>&gt; for <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where K: <a class='trait' href='../../../bitflags/__core/cmp/trait.Eq.html' title='bitflags::__core::cmp::Eq'>Eq</a> + <a class='trait' href='../../../bitflags/__core/hash/trait.Hash.html' title='bitflags::__core::hash::Hash'>Hash</a> + <a class='trait' href='../../../bitflags/__core/marker/trait.Copy.html' title='bitflags::__core::marker::Copy'>Copy</a>, S: <a class='trait' href='../../../bitflags/__core/hash/trait.BuildHasher.html' title='bitflags::__core::hash::BuildHasher'>BuildHasher</a>, V: <a class='trait' href='../../../bitflags/__core/marker/trait.Copy.html' title='bitflags::__core::marker::Copy'>Copy</a></span></code><span class="since">1.4.0</span></h3><div class='impl-items'><h4 id='method.extend-1' class='method'><code>fn <a href='../../../bitflags/__core/iter/trait.Extend.html#tymethod.extend' class='fnname'>extend</a>&lt;T&gt;(&amp;mut self, iter: T) <span class='where'>where T: <a class='trait' href='../../../bitflags/__core/iter/trait.IntoIterator.html' title='bitflags::__core::iter::IntoIterator'>IntoIterator</a>&lt;Item=<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>(</a>&amp;'a K, &amp;'a V<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>)</a>&gt;</span></code></h4>
</div><h3 id='derived_implementations'>Derived Implementations </h3><h3 class='impl'><code>impl&lt;K, V, S&gt; <a class='trait' href='../../../bitflags/__core/clone/trait.Clone.html' title='bitflags::__core::clone::Clone'>Clone</a> for <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt; <span class='where'>where S: <a class='trait' href='../../../bitflags/__core/clone/trait.Clone.html' title='bitflags::__core::clone::Clone'>Clone</a>, K: <a class='trait' href='../../../bitflags/__core/clone/trait.Clone.html' title='bitflags::__core::clone::Clone'>Clone</a>, V: <a class='trait' href='../../../bitflags/__core/clone/trait.Clone.html' title='bitflags::__core::clone::Clone'>Clone</a></span></code></h3><div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='../../../bitflags/__core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class='struct' href='../../../bitflags/__core/collections/struct.HashMap.html' title='bitflags::__core::collections::HashMap'>HashMap</a>&lt;K, V, S&gt;</code></h4>
<h4 id='method.clone_from' class='method'><code>fn <a href='../../../bitflags/__core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: &amp;Self)</code></h4>
</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>
</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 = "bitflags";
window.playgroundUrl = "";
</script>
<script src="../../../jquery.js"></script>
<script src="../../../main.js"></script>
<script defer src="../../../search-index.js"></script>
</body>
</html>