Files
google-apis-rs/hashbrown/struct.HashSet.html
2021-04-02 00:20:57 +08:00

611 lines
147 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 `HashSet` struct in crate `hashbrown`."><meta name="keywords" content="rust, rustlang, rust-lang, HashSet"><title>hashbrown::HashSet - 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="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></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><a href='../hashbrown/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct HashSet</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.capacity">capacity</a><a href="#method.clear">clear</a><a href="#method.contains">contains</a><a href="#method.difference">difference</a><a href="#method.drain">drain</a><a href="#method.drain_filter">drain_filter</a><a href="#method.get">get</a><a href="#method.get_or_insert">get_or_insert</a><a href="#method.get_or_insert_owned">get_or_insert_owned</a><a href="#method.get_or_insert_with">get_or_insert_with</a><a href="#method.hasher">hasher</a><a href="#method.insert">insert</a><a href="#method.intersection">intersection</a><a href="#method.is_disjoint">is_disjoint</a><a href="#method.is_empty">is_empty</a><a href="#method.is_subset">is_subset</a><a href="#method.is_superset">is_superset</a><a href="#method.iter">iter</a><a href="#method.len">len</a><a href="#method.remove">remove</a><a href="#method.replace">replace</a><a href="#method.reserve">reserve</a><a href="#method.retain">retain</a><a href="#method.shrink_to">shrink_to</a><a href="#method.shrink_to_fit">shrink_to_fit</a><a href="#method.symmetric_difference">symmetric_difference</a><a href="#method.take">take</a><a href="#method.try_reserve">try_reserve</a><a href="#method.union">union</a><a href="#method.with_capacity_and_hasher">with_capacity_and_hasher</a><a href="#method.with_hasher">with_hasher</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-BitAnd%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E">BitAnd&lt;&amp;&#39;_ HashSet&lt;T, S&gt;&gt;</a><a href="#impl-BitOr%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E">BitOr&lt;&amp;&#39;_ HashSet&lt;T, S&gt;&gt;</a><a href="#impl-BitXor%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E">BitXor&lt;&amp;&#39;_ HashSet&lt;T, S&gt;&gt;</a><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a><a href="#impl-Eq">Eq</a><a href="#impl-Extend%3C%26%27a%20T%3E">Extend&lt;&amp;&#39;a T&gt;</a><a href="#impl-Extend%3CT%3E">Extend&lt;T&gt;</a><a href="#impl-FromIterator%3CT%3E">FromIterator&lt;T&gt;</a><a href="#impl-IntoIterator">IntoIterator</a><a href="#impl-PartialEq%3CHashSet%3CT%2C%20S%3E%3E">PartialEq&lt;HashSet&lt;T, S&gt;&gt;</a><a href="#impl-Sub%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E">Sub&lt;&amp;&#39;_ HashSet&lt;T, S&gt;&gt;</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><a href="#impl-Unpin">Unpin</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a></div></div><p class="location"><a href="index.html">hashbrown</a></p><div id="sidebar-vars" data-name="HashSet" data-ty="struct" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" class="help-button">?</button>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">hashbrown</a>::<wbr><a class="struct" href="">HashSet</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/hashbrown/set.rs.html#114-116" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct HashSet&lt;T, S&nbsp;=&nbsp;<a class="enum" href="../hashbrown/hash_map/enum.DefaultHashBuilder.html" title="enum hashbrown::hash_map::DefaultHashBuilder">DefaultHashBuilder</a>&gt; { /* fields omitted */ }</pre></div><div class="docblock"><p>A hash set implemented as a <code>HashMap</code> where the value is <code>()</code>.</p>
<p>As with the <a href="struct.HashMap.html"><code>HashMap</code></a> type, a <code>HashSet</code> requires that the elements
implement the <a href="https://doc.rust-lang.org/std/cmp/trait.Eq.html"><code>Eq</code></a> and <a href="https://doc.rust-lang.org/std/hash/trait.Hash.html"><code>Hash</code></a> traits. 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 an item to be modified in such a way that the
item's hash, as determined by the <a href="https://doc.rust-lang.org/std/hash/trait.Hash.html"><code>Hash</code></a> trait, or its equality, as
determined by the <a href="https://doc.rust-lang.org/std/cmp/trait.Eq.html"><code>Eq</code></a> trait, changes while it is in the set. This is
normally only possible through <a href="https://doc.rust-lang.org/std/cell/struct.Cell.html"><code>Cell</code></a>, <a href="https://doc.rust-lang.org/std/cell/struct.RefCell.html"><code>RefCell</code></a>, global state, I/O, or
unsafe code.</p>
<p>It is also a logic error for the <a href="https://doc.rust-lang.org/std/hash/trait.Hash.html"><code>Hash</code></a> implementation of a key to panic.
This is generally only possible if the trait is implemented manually. If a
panic does occur then the contents of the <code>HashSet</code> may become corrupted and
some items may be dropped from the table.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="comment">// Type inference lets us omit an explicit type signature (which</span>
<span class="comment">// would be `HashSet&lt;String&gt;` in this example).</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">books</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="comment">// Add some books.</span>
<span class="ident">books</span>.<span class="ident">insert</span>(<span class="string">&quot;A Dance With Dragons&quot;</span>.<span class="ident">to_string</span>());
<span class="ident">books</span>.<span class="ident">insert</span>(<span class="string">&quot;To Kill a Mockingbird&quot;</span>.<span class="ident">to_string</span>());
<span class="ident">books</span>.<span class="ident">insert</span>(<span class="string">&quot;The Odyssey&quot;</span>.<span class="ident">to_string</span>());
<span class="ident">books</span>.<span class="ident">insert</span>(<span class="string">&quot;The Great Gatsby&quot;</span>.<span class="ident">to_string</span>());
<span class="comment">// Check for a specific one.</span>
<span class="kw">if</span> <span class="op">!</span><span class="ident">books</span>.<span class="ident">contains</span>(<span class="string">&quot;The Winds of Winter&quot;</span>) {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;We have {} books, but The Winds of Winter ain&#39;t one.&quot;</span>,
<span class="ident">books</span>.<span class="ident">len</span>());
}
<span class="comment">// Remove a book.</span>
<span class="ident">books</span>.<span class="ident">remove</span>(<span class="string">&quot;The Odyssey&quot;</span>);
<span class="comment">// Iterate over everything.</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">books</span> {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">book</span>);
}</pre></div>
<p>The easiest way to use <code>HashSet</code> with a custom type is to derive
<a href="https://doc.rust-lang.org/std/cmp/trait.Eq.html"><code>Eq</code></a> and <a href="https://doc.rust-lang.org/std/hash/trait.Hash.html"><code>Hash</code></a>. We must also derive <a href="https://doc.rust-lang.org/std/cmp/trait.PartialEq.html"><code>PartialEq</code></a>, this will in the
future be implied by <a href="https://doc.rust-lang.org/std/cmp/trait.Eq.html"><code>Eq</code></a>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</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">power</span>: <span class="ident">usize</span>,
}
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vikings</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="ident">vikings</span>.<span class="ident">insert</span>(<span class="ident">Viking</span> { <span class="ident">name</span>: <span class="string">&quot;Einar&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">power</span>: <span class="number">9</span> });
<span class="ident">vikings</span>.<span class="ident">insert</span>(<span class="ident">Viking</span> { <span class="ident">name</span>: <span class="string">&quot;Einar&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">power</span>: <span class="number">9</span> });
<span class="ident">vikings</span>.<span class="ident">insert</span>(<span class="ident">Viking</span> { <span class="ident">name</span>: <span class="string">&quot;Olaf&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">power</span>: <span class="number">4</span> });
<span class="ident">vikings</span>.<span class="ident">insert</span>(<span class="ident">Viking</span> { <span class="ident">name</span>: <span class="string">&quot;Harald&quot;</span>.<span class="ident">to_string</span>(), <span class="ident">power</span>: <span class="number">8</span> });
<span class="comment">// Use derived implementation to print the vikings.</span>
<span class="kw">for</span> <span class="ident">x</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;{:?}&quot;</span>, <span class="ident">x</span>);
}</pre></div>
<p>A <code>HashSet</code> with fixed list of elements can be initialized from an array:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">viking_names</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span><span class="op">&gt;</span> <span class="op">=</span>
[ <span class="string">&quot;Einar&quot;</span>, <span class="string">&quot;Olaf&quot;</span>, <span class="string">&quot;Harald&quot;</span> ].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="comment">// use the values stored in the set</span></pre></div>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#170-427" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.with_hasher" class="method"><code>pub const fn <a href="#method.with_hasher" class="fnname">with_hasher</a>(hasher: S) -&gt; Self</code><a class="srclink" href="../src/hashbrown/set.rs.html#198-202" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates a new empty hash set which will use the given hasher to hash
keys.</p>
<p>The hash set is also created with the default initial capacity.</p>
<p>Warning: <code>hasher</code> is normally randomly generated, and
is designed to allow <code>HashSet</code>s 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>
<p>The <code>hash_builder</code> passed should implement the <a href="../../std/hash/trait.BuildHasher.html"><code>BuildHasher</code></a> trait for
the HashMap to be useful, see its documentation for details.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">hash_map</span>::<span class="ident">DefaultHashBuilder</span>;
<span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> <span class="ident">DefaultHashBuilder</span>::<span class="ident">default</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">with_hasher</span>(<span class="ident">s</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">2</span>);</pre></div>
</div><h4 id="method.with_capacity_and_hasher" class="method"><code>pub fn <a href="#method.with_capacity_and_hasher" class="fnname">with_capacity_and_hasher</a>(capacity: usize, hasher: S) -&gt; Self</code><a class="srclink" href="../src/hashbrown/set.rs.html#231-235" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates an empty <code>HashSet</code> with the specified capacity, using
<code>hasher</code> to hash the keys.</p>
<p>The hash set will be able to hold at least <code>capacity</code> elements without
reallocating. If <code>capacity</code> is 0, the hash set will not allocate.</p>
<p>Warning: <code>hasher</code> is normally randomly generated, and
is designed to allow <code>HashSet</code>s 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>
<p>The <code>hash_builder</code> passed should implement the <a href="../../std/hash/trait.BuildHasher.html"><code>BuildHasher</code></a> trait for
the HashMap to be useful, see its documentation for details.</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">hash_map</span>::<span class="ident">DefaultHashBuilder</span>;
<span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> <span class="ident">DefaultHashBuilder</span>::<span class="ident">default</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">with_capacity_and_hasher</span>(<span class="number">10</span>, <span class="ident">s</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">1</span>);</pre></div>
</div><h4 id="method.capacity" class="method"><code>pub fn <a href="#method.capacity" class="fnname">capacity</a>(&amp;self) -&gt; usize</code><a class="srclink" href="../src/hashbrown/set.rs.html#247-249" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the number of elements the set can hold without reallocating.</p>
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">100</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">capacity</span>() <span class="op">&gt;</span><span class="op">=</span> <span class="number">100</span>);</pre></div>
</div><h4 id="method.iter" class="method"><code>pub fn <a href="#method.iter" class="fnname">iter</a>(&amp;self) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.Iter.html" title="struct hashbrown::hash_set::Iter">Iter</a>&lt;'_, T&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../hashbrown/hash_set/struct.Iter.html" title="struct hashbrown::hash_set::Iter">Iter</a>&lt;'a, K&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, K&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../hashbrown/hash_set/struct.Iter.html" title="struct hashbrown::hash_set::Iter">Iter</a>&lt;'a, K&gt;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="type">Item</a> = &amp;'a K;</span></code></span></div></span></span></code><a class="srclink" href="../src/hashbrown/set.rs.html#268-272" title="goto source code">[src]</a></h4><div class="docblock"><p>An iterator visiting all elements in arbitrary order.
The iterator element type is <code>&amp;'a T</code>.</p>
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="string">&quot;a&quot;</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="string">&quot;b&quot;</span>);
<span class="comment">// Will print in an arbitrary order.</span>
<span class="kw">for</span> <span class="ident">x</span> <span class="kw">in</span> <span class="ident">set</span>.<span class="ident">iter</span>() {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">x</span>);
}</pre></div>
</div><h4 id="method.len" class="method"><code>pub fn <a href="#method.len" class="fnname">len</a>(&amp;self) -&gt; usize</code><a class="srclink" href="../src/hashbrown/set.rs.html#287-289" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the number of elements in the set.</p>
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">len</span>(), <span class="number">0</span>);
<span class="ident">v</span>.<span class="ident">insert</span>(<span class="number">1</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">len</span>(), <span class="number">1</span>);</pre></div>
</div><h4 id="method.is_empty" class="method"><code>pub fn <a href="#method.is_empty" class="fnname">is_empty</a>(&amp;self) -&gt; bool</code><a class="srclink" href="../src/hashbrown/set.rs.html#304-306" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if the set contains no elements.</p>
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="ident">HashSet</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">insert</span>(<span class="number">1</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">v</span>.<span class="ident">is_empty</span>());</pre></div>
</div><h4 id="method.drain" class="method"><code>pub fn <a href="#method.drain" class="fnname">drain</a>(&amp;mut self) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.Drain.html" title="struct hashbrown::hash_set::Drain">Drain</a>&lt;'_, T&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../hashbrown/hash_set/struct.Drain.html" title="struct hashbrown::hash_set::Drain">Drain</a>&lt;'_, K&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;K&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../hashbrown/hash_set/struct.Drain.html" title="struct hashbrown::hash_set::Drain">Drain</a>&lt;'_, K&gt;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="type">Item</a> = K;</span></code></span></div></span></span></code><a class="srclink" href="../src/hashbrown/set.rs.html#326-330" title="goto source code">[src]</a></h4><div class="docblock"><p>Clears the set, returning all elements in an iterator.</p>
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">set</span>.<span class="ident">is_empty</span>());
<span class="comment">// print 1, 2, 3 in an arbitrary order</span>
<span class="kw">for</span> <span class="ident">i</span> <span class="kw">in</span> <span class="ident">set</span>.<span class="ident">drain</span>() {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">i</span>);
}
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">is_empty</span>());</pre></div>
</div><h4 id="method.retain" class="method"><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>(&amp;T) -&gt; bool,&nbsp;</span></code><a class="srclink" href="../src/hashbrown/set.rs.html#346-351" title="goto source code">[src]</a></h4><div class="docblock"><p>Retains only the elements specified by the predicate.</p>
<p>In other words, remove all elements <code>e</code> such that <code>f(&amp;e)</code> returns <code>false</code>.</p>
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">xs</span> <span class="op">=</span> [<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">xs</span>.<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="ident">set</span>.<span class="ident">retain</span>(<span class="op">|</span><span class="kw-2">&amp;</span><span class="ident">k</span><span class="op">|</span> <span class="ident">k</span> <span class="op">%</span> <span class="number">2</span> <span class="op">=</span><span class="op">=</span> <span class="number">0</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">len</span>(), <span class="number">3</span>);</pre></div>
</div><h4 id="method.drain_filter" class="method"><code>pub fn <a href="#method.drain_filter" class="fnname">drain_filter</a>&lt;F&gt;(&amp;mut self, f: F) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.DrainFilter.html" title="struct hashbrown::hash_set::DrainFilter">DrainFilter</a>&lt;'_, T, F&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../hashbrown/hash_set/struct.DrainFilter.html" title="struct hashbrown::hash_set::DrainFilter">DrainFilter</a>&lt;'_, K, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;K, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../hashbrown/hash_set/struct.DrainFilter.html" title="struct hashbrown::hash_set::DrainFilter">DrainFilter</a>&lt;'_, K, F&gt; <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>(&amp;K) -&gt; bool,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="type">Item</a> = K;</span></code></span></div></span></span> <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>(&amp;T) -&gt; bool,&nbsp;</span></code><a class="srclink" href="../src/hashbrown/set.rs.html#379-390" title="goto source code">[src]</a></h4><div class="docblock"><p>Drains elements which are true under the given predicate,
and returns an iterator over the removed items.</p>
<p>In other words, move all elements <code>e</code> such that <code>f(&amp;e)</code> returns <code>true</code> out
into another iterator.</p>
<p>When the returned DrainedFilter is dropped, any remaining elements that satisfy
the predicate are dropped from the set.</p>
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">8</span>).<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">drained</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">set</span>.<span class="ident">drain_filter</span>(<span class="op">|</span><span class="ident">v</span><span class="op">|</span> <span class="ident">v</span> <span class="op">%</span> <span class="number">2</span> <span class="op">=</span><span class="op">=</span> <span class="number">0</span>).<span class="ident">collect</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">evens</span> <span class="op">=</span> <span class="ident">drained</span>.<span class="ident">into_iter</span>().<span class="ident">collect</span>::<span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span><span class="op">&gt;</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">odds</span> <span class="op">=</span> <span class="ident">set</span>.<span class="ident">into_iter</span>().<span class="ident">collect</span>::<span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span><span class="op">&gt;</span>();
<span class="ident">evens</span>.<span class="ident">sort</span>();
<span class="ident">odds</span>.<span class="ident">sort</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">evens</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">2</span>, <span class="number">4</span>, <span class="number">6</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">odds</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>]);</pre></div>
</div><h4 id="method.clear" class="method"><code>pub fn <a href="#method.clear" class="fnname">clear</a>(&amp;mut self)</code><a class="srclink" href="../src/hashbrown/set.rs.html#405-407" title="goto source code">[src]</a></h4><div class="docblock"><p>Clears the set, removing all values.</p>
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="ident">v</span>.<span class="ident">insert</span>(<span class="number">1</span>);
<span class="ident">v</span>.<span class="ident">clear</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">v</span>.<span class="ident">is_empty</span>());</pre></div>
</div><h4 id="method.hasher" class="method"><code>pub fn <a href="#method.hasher" class="fnname">hasher</a>(&amp;self) -&gt; &amp;S</code><a class="srclink" href="../src/hashbrown/set.rs.html#424-426" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a reference to the set's <a href="https://doc.rust-lang.org/std/hash/trait.BuildHasher.html"><code>BuildHasher</code></a>.</p>
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">hash_map</span>::<span class="ident">DefaultHashBuilder</span>;
<span class="kw">let</span> <span class="ident">hasher</span> <span class="op">=</span> <span class="ident">DefaultHashBuilder</span>::<span class="ident">default</span>();
<span class="kw">let</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">with_hasher</span>(<span class="ident">hasher</span>);
<span class="kw">let</span> <span class="ident">hasher</span>: <span class="kw-2">&amp;</span><span class="ident">DefaultHashBuilder</span> <span class="op">=</span> <span class="ident">set</span>.<span class="ident">hasher</span>();</pre></div>
</div></div><h3 id="impl-1" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>,&nbsp;</span></code><a href="#impl-1" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#429-968" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.reserve" class="method"><code>pub fn <a href="#method.reserve" class="fnname">reserve</a>(&amp;mut self, additional: usize)</code><a class="srclink" href="../src/hashbrown/set.rs.html#451-453" title="goto source code">[src]</a></h4><div class="docblock"><p>Reserves capacity for at least <code>additional</code> more elements to be inserted
in the <code>HashSet</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-12" class="section-header"><a href="#examples-12">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="ident">set</span>.<span class="ident">reserve</span>(<span class="number">10</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">capacity</span>() <span class="op">&gt;</span><span class="op">=</span> <span class="number">10</span>);</pre></div>
</div><h4 id="method.try_reserve" class="method"><code>pub fn <a href="#method.try_reserve" class="fnname">try_reserve</a>(&amp;mut self, additional: usize) -&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="enum" href="../hashbrown/enum.TryReserveError.html" title="enum hashbrown::TryReserveError">TryReserveError</a>&gt;</code><a class="srclink" href="../src/hashbrown/set.rs.html#472-474" title="goto source code">[src]</a></h4><div class="docblock"><p>Tries to reserve capacity for at least <code>additional</code> more elements to be inserted
in the given <code>HashSet&lt;K,V&gt;</code>. The collection may reserve more space to avoid
frequent reallocations.</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-13" class="section-header"><a href="#examples-13">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="ident">set</span>.<span class="ident">try_reserve</span>(<span class="number">10</span>).<span class="ident">expect</span>(<span class="string">&quot;why is the test harness OOMing on 10 bytes?&quot;</span>);</pre></div>
</div><h4 id="method.shrink_to_fit" class="method"><code>pub fn <a href="#method.shrink_to_fit" class="fnname">shrink_to_fit</a>(&amp;mut self)</code><a class="srclink" href="../src/hashbrown/set.rs.html#493-495" title="goto source code">[src]</a></h4><div class="docblock"><p>Shrinks the capacity of the set 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-14" class="section-header"><a href="#examples-14">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">100</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">1</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">2</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">capacity</span>() <span class="op">&gt;</span><span class="op">=</span> <span class="number">100</span>);
<span class="ident">set</span>.<span class="ident">shrink_to_fit</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">capacity</span>() <span class="op">&gt;</span><span class="op">=</span> <span class="number">2</span>);</pre></div>
</div><h4 id="method.shrink_to" class="method"><code>pub fn <a href="#method.shrink_to" class="fnname">shrink_to</a>(&amp;mut self, min_capacity: usize)</code><a class="srclink" href="../src/hashbrown/set.rs.html#519-521" title="goto source code">[src]</a></h4><div class="docblock"><p>Shrinks the capacity of the set with a lower limit. It will drop
down no lower than the supplied limit while maintaining the internal rules
and possibly leaving some space in accordance with the resize policy.</p>
<p>Panics if the current capacity is smaller than the supplied
minimum capacity.</p>
<h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">with_capacity</span>(<span class="number">100</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">1</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">2</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">capacity</span>() <span class="op">&gt;</span><span class="op">=</span> <span class="number">100</span>);
<span class="ident">set</span>.<span class="ident">shrink_to</span>(<span class="number">10</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">capacity</span>() <span class="op">&gt;</span><span class="op">=</span> <span class="number">10</span>);
<span class="ident">set</span>.<span class="ident">shrink_to</span>(<span class="number">0</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">capacity</span>() <span class="op">&gt;</span><span class="op">=</span> <span class="number">2</span>);</pre></div>
</div><h4 id="method.difference" class="method"><code>pub fn <a href="#method.difference" class="fnname">difference</a>&lt;'a&gt;(&amp;'a self, other: &amp;'a Self) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.Difference.html" title="struct hashbrown::hash_set::Difference">Difference</a>&lt;'a, T, S&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../hashbrown/hash_set/struct.Difference.html" title="struct hashbrown::hash_set::Difference">Difference</a>&lt;'a, T, S&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../hashbrown/hash_set/struct.Difference.html" title="struct hashbrown::hash_set::Difference">Difference</a>&lt;'a, T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="type">Item</a> = &amp;'a T;</span></code></span></div></span></span></code><a class="srclink" href="../src/hashbrown/set.rs.html#547-552" title="goto source code">[src]</a></h4><div class="docblock"><p>Visits the values representing the difference,
i.e., the values that are in <code>self</code> but not in <code>other</code>.</p>
<h1 id="examples-16" class="section-header"><a href="#examples-16">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">a</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">b</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">4</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="comment">// Can be seen as `a - b`.</span>
<span class="kw">for</span> <span class="ident">x</span> <span class="kw">in</span> <span class="ident">a</span>.<span class="ident">difference</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>) {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">x</span>); <span class="comment">// Print 1</span>
}
<span class="kw">let</span> <span class="ident">diff</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">difference</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>).<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">diff</span>, [<span class="number">1</span>].<span class="ident">iter</span>().<span class="ident">collect</span>());
<span class="comment">// Note that difference is not symmetric,</span>
<span class="comment">// and `b - a` means something else:</span>
<span class="kw">let</span> <span class="ident">diff</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">b</span>.<span class="ident">difference</span>(<span class="kw-2">&amp;</span><span class="ident">a</span>).<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">diff</span>, [<span class="number">4</span>].<span class="ident">iter</span>().<span class="ident">collect</span>());</pre></div>
</div><h4 id="method.symmetric_difference" class="method"><code>pub fn <a href="#method.symmetric_difference" class="fnname">symmetric_difference</a>&lt;'a&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;'a self, <br>&nbsp;&nbsp;&nbsp;&nbsp;other: &amp;'a Self<br>) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.SymmetricDifference.html" title="struct hashbrown::hash_set::SymmetricDifference">SymmetricDifference</a>&lt;'a, T, S&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../hashbrown/hash_set/struct.SymmetricDifference.html" title="struct hashbrown::hash_set::SymmetricDifference">SymmetricDifference</a>&lt;'a, T, S&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../hashbrown/hash_set/struct.SymmetricDifference.html" title="struct hashbrown::hash_set::SymmetricDifference">SymmetricDifference</a>&lt;'a, T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="type">Item</a> = &amp;'a T;</span></code></span></div></span></span></code><a class="srclink" href="../src/hashbrown/set.rs.html#576-580" title="goto source code">[src]</a></h4><div class="docblock"><p>Visits the values representing the symmetric difference,
i.e., the values that are in <code>self</code> or in <code>other</code> but not in both.</p>
<h1 id="examples-17" class="section-header"><a href="#examples-17">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">a</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">b</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">4</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="comment">// Print 1, 4 in arbitrary order.</span>
<span class="kw">for</span> <span class="ident">x</span> <span class="kw">in</span> <span class="ident">a</span>.<span class="ident">symmetric_difference</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>) {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">x</span>);
}
<span class="kw">let</span> <span class="ident">diff1</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">symmetric_difference</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>).<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">diff2</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">b</span>.<span class="ident">symmetric_difference</span>(<span class="kw-2">&amp;</span><span class="ident">a</span>).<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">diff1</span>, <span class="ident">diff2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">diff1</span>, [<span class="number">1</span>, <span class="number">4</span>].<span class="ident">iter</span>().<span class="ident">collect</span>());</pre></div>
</div><h4 id="method.intersection" class="method"><code>pub fn <a href="#method.intersection" class="fnname">intersection</a>&lt;'a&gt;(&amp;'a self, other: &amp;'a Self) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.Intersection.html" title="struct hashbrown::hash_set::Intersection">Intersection</a>&lt;'a, T, S&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../hashbrown/hash_set/struct.Intersection.html" title="struct hashbrown::hash_set::Intersection">Intersection</a>&lt;'a, T, S&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../hashbrown/hash_set/struct.Intersection.html" title="struct hashbrown::hash_set::Intersection">Intersection</a>&lt;'a, T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="type">Item</a> = &amp;'a T;</span></code></span></div></span></span></code><a class="srclink" href="../src/hashbrown/set.rs.html#601-611" title="goto source code">[src]</a></h4><div class="docblock"><p>Visits the values representing the intersection,
i.e., the values that are both in <code>self</code> and <code>other</code>.</p>
<h1 id="examples-18" class="section-header"><a href="#examples-18">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">a</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">b</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">4</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="comment">// Print 2, 3 in arbitrary order.</span>
<span class="kw">for</span> <span class="ident">x</span> <span class="kw">in</span> <span class="ident">a</span>.<span class="ident">intersection</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>) {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">x</span>);
}
<span class="kw">let</span> <span class="ident">intersection</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">intersection</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>).<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">intersection</span>, [<span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">collect</span>());</pre></div>
</div><h4 id="method.union" class="method"><code>pub fn <a href="#method.union" class="fnname">union</a>&lt;'a&gt;(&amp;'a self, other: &amp;'a Self) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.Union.html" title="struct hashbrown::hash_set::Union">Union</a>&lt;'a, T, S&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../hashbrown/hash_set/struct.Union.html" title="struct hashbrown::hash_set::Union">Union</a>&lt;'a, T, S&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../hashbrown/hash_set/struct.Union.html" title="struct hashbrown::hash_set::Union">Union</a>&lt;'a, T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="type">Item</a> = &amp;'a T;</span></code></span></div></span></span></code><a class="srclink" href="../src/hashbrown/set.rs.html#632-641" title="goto source code">[src]</a></h4><div class="docblock"><p>Visits the values representing the union,
i.e., all the values in <code>self</code> or <code>other</code>, without duplicates.</p>
<h1 id="examples-19" class="section-header"><a href="#examples-19">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">a</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">b</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">4</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="comment">// Print 1, 2, 3, 4 in arbitrary order.</span>
<span class="kw">for</span> <span class="ident">x</span> <span class="kw">in</span> <span class="ident">a</span>.<span class="ident">union</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>) {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">x</span>);
}
<span class="kw">let</span> <span class="ident">union</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">union</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>).<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">union</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>].<span class="ident">iter</span>().<span class="ident">collect</span>());</pre></div>
</div><h4 id="method.contains" class="method"><code>pub fn <a href="#method.contains" class="fnname">contains</a>&lt;Q:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;self, value: &amp;Q) -&gt; bool <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a>,&nbsp;</span></code><a class="srclink" href="../src/hashbrown/set.rs.html#662-668" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if the set contains a value.</p>
<p>The value may be any borrowed form of the set's value type, but
<a href="https://doc.rust-lang.org/std/hash/trait.Hash.html"><code>Hash</code></a> and <a href="https://doc.rust-lang.org/std/cmp/trait.Eq.html"><code>Eq</code></a> on the borrowed form <em>must</em> match those for
the value type.</p>
<h1 id="examples-20" class="section-header"><a href="#examples-20">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">contains</span>(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="bool-val">true</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">contains</span>(<span class="kw-2">&amp;</span><span class="number">4</span>), <span class="bool-val">false</span>);</pre></div>
</div><h4 id="method.get" class="method"><code>pub fn <a href="#method.get" class="fnname">get</a>&lt;Q:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;self, value: &amp;Q) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a>,&nbsp;</span></code><a class="srclink" href="../src/hashbrown/set.rs.html#689-699" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns a reference to the value in the set, if any, that is equal to the given value.</p>
<p>The value may be any borrowed form of the set's value type, but
<a href="https://doc.rust-lang.org/std/hash/trait.Hash.html"><code>Hash</code></a> and <a href="https://doc.rust-lang.org/std/cmp/trait.Eq.html"><code>Eq</code></a> on the borrowed form <em>must</em> match those for
the value type.</p>
<h1 id="examples-21" class="section-header"><a href="#examples-21">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">get</span>(<span class="kw-2">&amp;</span><span class="number">2</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">get</span>(<span class="kw-2">&amp;</span><span class="number">4</span>), <span class="prelude-val">None</span>);</pre></div>
</div><h4 id="method.get_or_insert" class="method"><code>pub fn <a href="#method.get_or_insert" class="fnname">get_or_insert</a>(&amp;mut self, value: T) -&gt; &amp;T</code><a class="srclink" href="../src/hashbrown/set.rs.html#716-724" title="goto source code">[src]</a></h4><div class="docblock"><p>Inserts the given <code>value</code> into the set if it is not present, then
returns a reference to the value in the set.</p>
<h1 id="examples-22" class="section-header"><a href="#examples-22">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">len</span>(), <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">get_or_insert</span>(<span class="number">2</span>), <span class="kw-2">&amp;</span><span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">get_or_insert</span>(<span class="number">100</span>), <span class="kw-2">&amp;</span><span class="number">100</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">len</span>(), <span class="number">4</span>); <span class="comment">// 100 was inserted</span></pre></div>
</div><h4 id="method.get_or_insert_owned" class="method"><code>pub fn <a href="#method.get_or_insert_owned" class="fnname">get_or_insert_owned</a>&lt;Q:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, value: &amp;Q) -&gt; &amp;T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a>&lt;Owned = T&gt;,&nbsp;</span></code><a class="srclink" href="../src/hashbrown/set.rs.html#745-757" title="goto source code">[src]</a></h4><div class="docblock"><p>Inserts an owned copy of the given <code>value</code> into the set if it is not
present, then returns a reference to the value in the set.</p>
<h1 id="examples-23" class="section-header"><a href="#examples-23">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="string">&quot;cat&quot;</span>, <span class="string">&quot;dog&quot;</span>, <span class="string">&quot;horse&quot;</span>]
.<span class="ident">iter</span>().<span class="ident">map</span>(<span class="op">|</span><span class="kw-2">&amp;</span><span class="ident">pet</span><span class="op">|</span> <span class="ident">pet</span>.<span class="ident">to_owned</span>()).<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">len</span>(), <span class="number">3</span>);
<span class="kw">for</span> <span class="kw-2">&amp;</span><span class="ident">pet</span> <span class="kw">in</span> <span class="kw-2">&amp;</span>[<span class="string">&quot;cat&quot;</span>, <span class="string">&quot;dog&quot;</span>, <span class="string">&quot;fish&quot;</span>] {
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="ident">set</span>.<span class="ident">get_or_insert_owned</span>(<span class="ident">pet</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">value</span>, <span class="ident">pet</span>);
}
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">len</span>(), <span class="number">4</span>); <span class="comment">// a new &quot;fish&quot; was inserted</span></pre></div>
</div><h4 id="method.get_or_insert_with" class="method"><code>pub fn <a href="#method.get_or_insert_with" class="fnname">get_or_insert_with</a>&lt;Q:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, F&gt;(&amp;mut self, value: &amp;Q, f: F) -&gt; &amp;T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;Q) -&gt; T,&nbsp;</span></code><a class="srclink" href="../src/hashbrown/set.rs.html#778-791" title="goto source code">[src]</a></h4><div class="docblock"><p>Inserts a value computed from <code>f</code> into the set if the given <code>value</code> is
not present, then returns a reference to the value in the set.</p>
<h1 id="examples-24" class="section-header"><a href="#examples-24">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="string">&quot;cat&quot;</span>, <span class="string">&quot;dog&quot;</span>, <span class="string">&quot;horse&quot;</span>]
.<span class="ident">iter</span>().<span class="ident">map</span>(<span class="op">|</span><span class="kw-2">&amp;</span><span class="ident">pet</span><span class="op">|</span> <span class="ident">pet</span>.<span class="ident">to_owned</span>()).<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">len</span>(), <span class="number">3</span>);
<span class="kw">for</span> <span class="kw-2">&amp;</span><span class="ident">pet</span> <span class="kw">in</span> <span class="kw-2">&amp;</span>[<span class="string">&quot;cat&quot;</span>, <span class="string">&quot;dog&quot;</span>, <span class="string">&quot;fish&quot;</span>] {
<span class="kw">let</span> <span class="ident">value</span> <span class="op">=</span> <span class="ident">set</span>.<span class="ident">get_or_insert_with</span>(<span class="ident">pet</span>, <span class="ident">str</span>::<span class="ident">to_owned</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">value</span>, <span class="ident">pet</span>);
}
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">len</span>(), <span class="number">4</span>); <span class="comment">// a new &quot;fish&quot; was inserted</span></pre></div>
</div><h4 id="method.is_disjoint" class="method"><code>pub fn <a href="#method.is_disjoint" class="fnname">is_disjoint</a>(&amp;self, other: &amp;Self) -&gt; bool</code><a class="srclink" href="../src/hashbrown/set.rs.html#810-812" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if <code>self</code> has no elements in common with <code>other</code>.
This is equivalent to checking for an empty intersection.</p>
<h1 id="examples-25" class="section-header"><a href="#examples-25">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">a</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">is_disjoint</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>), <span class="bool-val">true</span>);
<span class="ident">b</span>.<span class="ident">insert</span>(<span class="number">4</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">is_disjoint</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>), <span class="bool-val">true</span>);
<span class="ident">b</span>.<span class="ident">insert</span>(<span class="number">1</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">is_disjoint</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>), <span class="bool-val">false</span>);</pre></div>
</div><h4 id="method.is_subset" class="method"><code>pub fn <a href="#method.is_subset" class="fnname">is_subset</a>(&amp;self, other: &amp;Self) -&gt; bool</code><a class="srclink" href="../src/hashbrown/set.rs.html#831-833" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if the set is a subset of another,
i.e., <code>other</code> contains at least all the values in <code>self</code>.</p>
<h1 id="examples-26" class="section-header"><a href="#examples-26">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">sup</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">is_subset</span>(<span class="kw-2">&amp;</span><span class="ident">sup</span>), <span class="bool-val">true</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">is_subset</span>(<span class="kw-2">&amp;</span><span class="ident">sup</span>), <span class="bool-val">true</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">4</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">is_subset</span>(<span class="kw-2">&amp;</span><span class="ident">sup</span>), <span class="bool-val">false</span>);</pre></div>
</div><h4 id="method.is_superset" class="method"><code>pub fn <a href="#method.is_superset" class="fnname">is_superset</a>(&amp;self, other: &amp;Self) -&gt; bool</code><a class="srclink" href="../src/hashbrown/set.rs.html#856-858" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if the set is a superset of another,
i.e., <code>self</code> contains at least all the values in <code>other</code>.</p>
<h1 id="examples-27" class="section-header"><a href="#examples-27">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">sub</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">is_superset</span>(<span class="kw-2">&amp;</span><span class="ident">sub</span>), <span class="bool-val">false</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">0</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">1</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">is_superset</span>(<span class="kw-2">&amp;</span><span class="ident">sub</span>), <span class="bool-val">false</span>);
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">is_superset</span>(<span class="kw-2">&amp;</span><span class="ident">sub</span>), <span class="bool-val">true</span>);</pre></div>
</div><h4 id="method.insert" class="method"><code>pub fn <a href="#method.insert" class="fnname">insert</a>(&amp;mut self, value: T) -&gt; bool</code><a class="srclink" href="../src/hashbrown/set.rs.html#878-880" title="goto source code">[src]</a></h4><div class="docblock"><p>Adds a value to the set.</p>
<p>If the set did not have this value present, <code>true</code> is returned.</p>
<p>If the set did have this value present, <code>false</code> is returned.</p>
<h1 id="examples-28" class="section-header"><a href="#examples-28">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">2</span>), <span class="bool-val">true</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">2</span>), <span class="bool-val">false</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">len</span>(), <span class="number">1</span>);</pre></div>
</div><h4 id="method.replace" class="method"><code>pub fn <a href="#method.replace" class="fnname">replace</a>(&amp;mut self, value: T) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;T&gt;</code><a class="srclink" href="../src/hashbrown/set.rs.html#898-906" title="goto source code">[src]</a></h4><div class="docblock"><p>Adds a value to the set, replacing the existing value, if any, that is equal to the given
one. Returns the replaced value.</p>
<h1 id="examples-29" class="section-header"><a href="#examples-29">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="ident">Vec</span>::<span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span>::<span class="ident">new</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">get</span>(<span class="kw-2">&amp;</span>[][..]).<span class="ident">unwrap</span>().<span class="ident">capacity</span>(), <span class="number">0</span>);
<span class="ident">set</span>.<span class="ident">replace</span>(<span class="ident">Vec</span>::<span class="ident">with_capacity</span>(<span class="number">10</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">get</span>(<span class="kw-2">&amp;</span>[][..]).<span class="ident">unwrap</span>().<span class="ident">capacity</span>(), <span class="number">10</span>);</pre></div>
</div><h4 id="method.remove" class="method"><code>pub fn <a href="#method.remove" class="fnname">remove</a>&lt;Q:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, value: &amp;Q) -&gt; bool <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a>,&nbsp;</span></code><a class="srclink" href="../src/hashbrown/set.rs.html#930-936" title="goto source code">[src]</a></h4><div class="docblock"><p>Removes a value from the set. Returns whether the value was
present in the set.</p>
<p>The value may be any borrowed form of the set's value type, but
<a href="https://doc.rust-lang.org/std/hash/trait.Hash.html"><code>Hash</code></a> and <a href="https://doc.rust-lang.org/std/cmp/trait.Eq.html"><code>Eq</code></a> on the borrowed form <em>must</em> match those for
the value type.</p>
<h1 id="examples-30" class="section-header"><a href="#examples-30">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">remove</span>(<span class="kw-2">&amp;</span><span class="number">2</span>), <span class="bool-val">true</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">remove</span>(<span class="kw-2">&amp;</span><span class="number">2</span>), <span class="bool-val">false</span>);</pre></div>
</div><h4 id="method.take" class="method"><code>pub fn <a href="#method.take" class="fnname">take</a>&lt;Q:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, value: &amp;Q) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a>,&nbsp;</span></code><a class="srclink" href="../src/hashbrown/set.rs.html#957-967" title="goto source code">[src]</a></h4><div class="docblock"><p>Removes and returns the value in the set, if any, that is equal to the given one.</p>
<p>The value may be any borrowed form of the set's value type, but
<a href="https://doc.rust-lang.org/std/hash/trait.Hash.html"><code>Hash</code></a> and <a href="https://doc.rust-lang.org/std/cmp/trait.Eq.html"><code>Eq</code></a> on the borrowed form <em>must</em> match those for
the value type.</p>
<h1 id="examples-31" class="section-header"><a href="#examples-31">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">cloned</span>().<span class="ident">collect</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">take</span>(<span class="kw-2">&amp;</span><span class="number">2</span>), <span class="prelude-val">Some</span>(<span class="number">2</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">set</span>.<span class="ident">take</span>(<span class="kw-2">&amp;</span><span class="number">2</span>), <span class="prelude-val">None</span>);</pre></div>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-BitAnd%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitAnd.html" title="trait core::ops::bit::BitAnd">BitAnd</a>&lt;&amp;'_ <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;&gt; for &amp;<a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,&nbsp;</span></code><a href="#impl-BitAnd%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#1105-1135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitAnd.html#associatedtype.Output" class="type">Output</a> = <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code></h4><div class='docblock'><p>The resulting type after applying the <code>&amp;</code> operator.</p>
</div><h4 id="method.bitand" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitAnd.html#tymethod.bitand" class="fnname">bitand</a>(self, rhs: &amp;<a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code><a class="srclink" href="../src/hashbrown/set.rs.html#1132-1134" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the intersection of <code>self</code> and <code>rhs</code> as a new <code>HashSet&lt;T, S&gt;</code>.</p>
<h1 id="examples-33" class="section-header"><a href="#examples-33">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">a</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">into_iter</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">b</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>].<span class="ident">into_iter</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">set</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">a</span> <span class="op">&amp;</span> <span class="kw-2">&amp;</span><span class="ident">b</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">i</span> <span class="op">=</span> <span class="number">0</span>;
<span class="kw">let</span> <span class="ident">expected</span> <span class="op">=</span> [<span class="number">2</span>, <span class="number">3</span>];
<span class="kw">for</span> <span class="ident">x</span> <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">set</span> {
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">expected</span>.<span class="ident">contains</span>(<span class="ident">x</span>));
<span class="ident">i</span> <span class="op">+</span><span class="op">=</span> <span class="number">1</span>;
}
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">i</span>, <span class="ident">expected</span>.<span class="ident">len</span>());</pre></div>
</div></div><h3 id="impl-BitOr%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOr.html" title="trait core::ops::bit::BitOr">BitOr</a>&lt;&amp;'_ <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;&gt; for &amp;<a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,&nbsp;</span></code><a href="#impl-BitOr%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#1073-1103" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output-2" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOr.html#associatedtype.Output" class="type">Output</a> = <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code></h4><div class='docblock'><p>The resulting type after applying the <code>|</code> operator.</p>
</div><h4 id="method.bitor" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitOr.html#tymethod.bitor" class="fnname">bitor</a>(self, rhs: &amp;<a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code><a class="srclink" href="../src/hashbrown/set.rs.html#1100-1102" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the union of <code>self</code> and <code>rhs</code> as a new <code>HashSet&lt;T, S&gt;</code>.</p>
<h1 id="examples-34" class="section-header"><a href="#examples-34">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">a</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">into_iter</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">b</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>].<span class="ident">into_iter</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">set</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">a</span> <span class="op">|</span> <span class="kw-2">&amp;</span><span class="ident">b</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">i</span> <span class="op">=</span> <span class="number">0</span>;
<span class="kw">let</span> <span class="ident">expected</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>];
<span class="kw">for</span> <span class="ident">x</span> <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">set</span> {
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">expected</span>.<span class="ident">contains</span>(<span class="ident">x</span>));
<span class="ident">i</span> <span class="op">+</span><span class="op">=</span> <span class="number">1</span>;
}
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">i</span>, <span class="ident">expected</span>.<span class="ident">len</span>());</pre></div>
</div></div><h3 id="impl-BitXor%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitXor.html" title="trait core::ops::bit::BitXor">BitXor</a>&lt;&amp;'_ <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;&gt; for &amp;<a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,&nbsp;</span></code><a href="#impl-BitXor%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#1137-1167" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output-3" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitXor.html#associatedtype.Output" class="type">Output</a> = <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code></h4><div class='docblock'><p>The resulting type after applying the <code>^</code> operator.</p>
</div><h4 id="method.bitxor" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/bit/trait.BitXor.html#tymethod.bitxor" class="fnname">bitxor</a>(self, rhs: &amp;<a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code><a class="srclink" href="../src/hashbrown/set.rs.html#1164-1166" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the symmetric difference of <code>self</code> and <code>rhs</code> as a new <code>HashSet&lt;T, S&gt;</code>.</p>
<h1 id="examples-35" class="section-header"><a href="#examples-35">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">a</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">into_iter</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">b</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>].<span class="ident">into_iter</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">set</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">a</span> <span class="op">^</span> <span class="kw-2">&amp;</span><span class="ident">b</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">i</span> <span class="op">=</span> <span class="number">0</span>;
<span class="kw">let</span> <span class="ident">expected</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>, <span class="number">5</span>];
<span class="kw">for</span> <span class="ident">x</span> <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">set</span> {
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">expected</span>.<span class="ident">contains</span>(<span class="ident">x</span>));
<span class="ident">i</span> <span class="op">+</span><span class="op">=</span> <span class="number">1</span>;
}
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">i</span>, <span class="ident">expected</span>.<span class="ident">len</span>());</pre></div>
</div></div><h3 id="impl-Clone" class="impl"><code class="in-band">impl&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, S:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; <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="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#118-128" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&amp;self) -&gt; Self</code><a class="srclink" href="../src/hashbrown/set.rs.html#119-123" title="goto source code">[src]</a></h4><div class='docblock hidden'><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 hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&amp;mut self, source: &amp;Self)</code><a class="srclink" href="../src/hashbrown/set.rs.html#125-127" title="goto source code">[src]</a></h4><div class='docblock hidden'><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"><code class="in-band">impl&lt;T, S&gt; <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="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>,&nbsp;</span></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#991-999" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.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>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../src/hashbrown/set.rs.html#996-998" title="goto source code">[src]</a></h4><div class='docblock hidden'><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-Default" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,&nbsp;</span></code><a href="#impl-Default" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#1060-1071" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.default" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default" class="fnname">default</a>() -&gt; Self</code><a class="srclink" href="../src/hashbrown/set.rs.html#1066-1070" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates an empty <code>HashSet&lt;T, S&gt;</code> with the <code>Default</code> value for the hasher.</p>
</div></div><h3 id="impl-Eq" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>,&nbsp;</span></code><a href="#impl-Eq" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#984-989" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Extend%3C%26%27a%20T%3E" class="impl"><code class="in-band">impl&lt;'a, T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html" title="trait core::iter::traits::collect::Extend">Extend</a>&lt;&amp;'a T&gt; for <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'a + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>,&nbsp;</span></code><a href="#impl-Extend%3C%26%27a%20T%3E" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#1037-1058" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.extend-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html#tymethod.extend" class="fnname">extend</a>&lt;I:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&lt;Item = &amp;'a T&gt;&gt;(&amp;mut self, iter: I)</code><a class="srclink" href="../src/hashbrown/set.rs.html#1043-1045" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extends a collection with the contents of an iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html#tymethod.extend">Read more</a></p>
</div><h4 id="method.extend_one-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html#method.extend_one" class="fnname">extend_one</a>(&amp;mut self, item: A)</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/iter/traits/collect.rs.html#340" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>extend_one</code>)</div></div><div class='docblock hidden'><p>Extends a collection with exactly one element.</p>
</div><h4 id="method.extend_reserve-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html#method.extend_reserve" class="fnname">extend_reserve</a>(&amp;mut self, additional: usize)</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/iter/traits/collect.rs.html#348" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>extend_one</code>)</div></div><div class='docblock hidden'><p>Reserves capacity in a collection for the given number of additional elements. <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html#method.extend_reserve">Read more</a></p>
</div></div><h3 id="impl-Extend%3CT%3E" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html" title="trait core::iter::traits::collect::Extend">Extend</a>&lt;T&gt; for <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>,&nbsp;</span></code><a href="#impl-Extend%3CT%3E" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#1014-1035" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.extend" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html#tymethod.extend" class="fnname">extend</a>&lt;I:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&lt;Item = T&gt;&gt;(&amp;mut self, iter: I)</code><a class="srclink" href="../src/hashbrown/set.rs.html#1020-1022" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extends a collection with the contents of an iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html#tymethod.extend">Read more</a></p>
</div><h4 id="method.extend_one" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html#method.extend_one" class="fnname">extend_one</a>(&amp;mut self, item: A)</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/iter/traits/collect.rs.html#340" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>extend_one</code>)</div></div><div class='docblock hidden'><p>Extends a collection with exactly one element.</p>
</div><h4 id="method.extend_reserve" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html#method.extend_reserve" class="fnname">extend_reserve</a>(&amp;mut self, additional: usize)</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/iter/traits/collect.rs.html#348" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>extend_one</code>)</div></div><div class='docblock hidden'><p>Reserves capacity in a collection for the given number of additional elements. <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.Extend.html#method.extend_reserve">Read more</a></p>
</div></div><h3 id="impl-FromIterator%3CT%3E" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.FromIterator.html" title="trait core::iter::traits::collect::FromIterator">FromIterator</a>&lt;T&gt; for <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,&nbsp;</span></code><a href="#impl-FromIterator%3CT%3E" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#1001-1012" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from_iter" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.FromIterator.html#tymethod.from_iter" class="fnname">from_iter</a>&lt;I:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&lt;Item = T&gt;&gt;(iter: I) -&gt; Self</code><a class="srclink" href="../src/hashbrown/set.rs.html#1007-1011" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Creates a value from an iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.FromIterator.html#tymethod.from_iter">Read more</a></p>
</div></div><h3 id="impl-IntoIterator" class="impl"><code class="in-band">impl&lt;'a, T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a> for &amp;'a <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code><a href="#impl-IntoIterator" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#1299-1307" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Item" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.Item" class="type">Item</a> = &amp;'a T</code></h4><div class='docblock'><p>The type of the elements being iterated over.</p>
</div><h4 id="associatedtype.IntoIter" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.IntoIter" class="type">IntoIter</a> = <a class="struct" href="../hashbrown/hash_set/struct.Iter.html" title="struct hashbrown::hash_set::Iter">Iter</a>&lt;'a, T&gt;</code></h4><div class='docblock'><p>Which kind of iterator are we turning this into?</p>
</div><h4 id="method.into_iter" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#tymethod.into_iter" class="fnname">into_iter</a>(self) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.Iter.html" title="struct hashbrown::hash_set::Iter">Iter</a>&lt;'a, T&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../hashbrown/hash_set/struct.Iter.html" title="struct hashbrown::hash_set::Iter">Iter</a>&lt;'a, K&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, K&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../hashbrown/hash_set/struct.Iter.html" title="struct hashbrown::hash_set::Iter">Iter</a>&lt;'a, K&gt;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="type">Item</a> = &amp;'a K;</span></code></span></div></span></span></code><a class="srclink" href="../src/hashbrown/set.rs.html#1304-1306" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Creates an iterator from a value. <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#tymethod.into_iter">Read more</a></p>
</div></div><h3 id="impl-IntoIterator-1" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a> for <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code><a href="#impl-IntoIterator-1" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#1309-1339" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Item-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.Item" class="type">Item</a> = T</code></h4><div class='docblock'><p>The type of the elements being iterated over.</p>
</div><h4 id="associatedtype.IntoIter-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.IntoIter" class="type">IntoIter</a> = <a class="struct" href="../hashbrown/hash_set/struct.IntoIter.html" title="struct hashbrown::hash_set::IntoIter">IntoIter</a>&lt;T&gt;</code></h4><div class='docblock'><p>Which kind of iterator are we turning this into?</p>
</div><h4 id="method.into_iter-1" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#tymethod.into_iter" class="fnname">into_iter</a>(self) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.IntoIter.html" title="struct hashbrown::hash_set::IntoIter">IntoIter</a>&lt;T&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../hashbrown/hash_set/struct.IntoIter.html" title="struct hashbrown::hash_set::IntoIter">IntoIter</a>&lt;K&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;K&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="struct" href="../hashbrown/hash_set/struct.IntoIter.html" title="struct hashbrown::hash_set::IntoIter">IntoIter</a>&lt;K&gt;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" class="type">Item</a> = K;</span></code></span></div></span></span></code><a class="srclink" href="../src/hashbrown/set.rs.html#1334-1338" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates a consuming iterator, that is, one that moves each value out
of the set in arbitrary order. The set cannot be used after calling
this.</p>
<h1 id="examples-36" class="section-header"><a href="#examples-36">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">set</span> <span class="op">=</span> <span class="ident">HashSet</span>::<span class="ident">new</span>();
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="string">&quot;a&quot;</span>.<span class="ident">to_string</span>());
<span class="ident">set</span>.<span class="ident">insert</span>(<span class="string">&quot;b&quot;</span>.<span class="ident">to_string</span>());
<span class="comment">// Not possible to collect to a Vec&lt;String&gt; with a regular `.iter()`.</span>
<span class="kw">let</span> <span class="ident">v</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">set</span>.<span class="ident">into_iter</span>().<span class="ident">collect</span>();
<span class="comment">// Will print in an arbitrary order.</span>
<span class="kw">for</span> <span class="ident">x</span> <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">v</span> {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">x</span>);
}</pre></div>
</div></div><h3 id="impl-PartialEq%3CHashSet%3CT%2C%20S%3E%3E" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&lt;<a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;&gt; for <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>,&nbsp;</span></code><a href="#impl-PartialEq%3CHashSet%3CT%2C%20S%3E%3E" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#970-982" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.eq" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">eq</a>(&amp;self, other: &amp;Self) -&gt; bool</code><a class="srclink" href="../src/hashbrown/set.rs.html#975-981" title="goto source code">[src]</a></h4><div class='docblock hidden'><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 hidden"><code><span class="docblock attributes">#[must_use]</span>pub fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&amp;self, other: &amp;Rhs) -&gt; bool</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 id="impl-Sub%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html" title="trait core::ops::arith::Sub">Sub</a>&lt;&amp;'_ <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;&gt; for &amp;<a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,&nbsp;</span></code><a href="#impl-Sub%3C%26%27_%20HashSet%3CT%2C%20S%3E%3E" class="anchor"></a><a class="srclink" href="../src/hashbrown/set.rs.html#1169-1199" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html#associatedtype.Output" class="type">Output</a> = <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code></h4><div class='docblock'><p>The resulting type after applying the <code>-</code> operator.</p>
</div><h4 id="method.sub" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/arith/trait.Sub.html#tymethod.sub" class="fnname">sub</a>(self, rhs: &amp;<a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;) -&gt; <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt;</code><a class="srclink" href="../src/hashbrown/set.rs.html#1196-1198" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the difference of <code>self</code> and <code>rhs</code> as a new <code>HashSet&lt;T, S&gt;</code>.</p>
<h1 id="examples-32" class="section-header"><a href="#examples-32">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">hashbrown</span>::<span class="ident">HashSet</span>;
<span class="kw">let</span> <span class="ident">a</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">into_iter</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">b</span>: <span class="ident">HashSet</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>].<span class="ident">into_iter</span>().<span class="ident">collect</span>();
<span class="kw">let</span> <span class="ident">set</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">a</span> <span class="op">-</span> <span class="kw-2">&amp;</span><span class="ident">b</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">i</span> <span class="op">=</span> <span class="number">0</span>;
<span class="kw">let</span> <span class="ident">expected</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>];
<span class="kw">for</span> <span class="ident">x</span> <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">set</span> {
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">expected</span>.<span class="ident">contains</span>(<span class="ident">x</span>));
<span class="ident">i</span> <span class="op">+</span><span class="op">=</span> <span class="number">1</span>;
}
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">i</span>, <span class="ident">expected</span>.<span class="ident">len</span>());</pre></div>
</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"><code class="in-band">impl&lt;T, S&gt; <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="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,&nbsp;</span></code><a href="#impl-Send" class="anchor"></a><a class="srclink" href="../src/hashbrown/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl&lt;T, S&gt; <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="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>,&nbsp;</span></code><a href="#impl-Sync" class="anchor"></a><a class="srclink" href="../src/hashbrown/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl&lt;T, S&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../hashbrown/hash_set/struct.HashSet.html" title="struct hashbrown::hash_set::HashSet">HashSet</a>&lt;T, S&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,&nbsp;</span></code><a href="#impl-Unpin" class="anchor"></a><a class="srclink" href="../src/hashbrown/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#207-211" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; &amp;T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214-218" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&amp;mut self) -&gt; &amp;mut T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#215" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-549" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -&gt; T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#546" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,&nbsp;</span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#534-541" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -&gt; U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#538" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-ToOwned" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></code><a href="#impl-ToOwned" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#80-92" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Owned" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="type">Owned</a> = T</code></h4><div class='docblock'><p>The resulting type after obtaining ownership.</p>
</div><h4 id="method.to_owned" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">to_owned</a>(&amp;self) -&gt; T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#85" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
</div><h4 id="method.clone_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&amp;self, target: &amp;mut T)</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#89" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><details><summary><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code>)</summary><p>recently added</p>
</details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,&nbsp;</span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#582-591" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#588" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#568-577" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#574" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="hashbrown"></div>
<script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>