<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="`IndexMap` is a hash table where the iteration order of the key-value pairs is independent of the hash values of the keys."><title>indexmap - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><linkrel="stylesheet"href="../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet"href="../static.files/rustdoc-dd39b87e5fcfba68.css"><metaname="rustdoc-vars"data-root-path="../"data-static-root-path="../static.files/"data-current-crate="indexmap"data-themes=""data-resource-suffix=""data-rustdoc-version="1.80.0 (051478957 2024-07-21)"data-channel="1.80.0"data-search-js="search-d52510db62a78183.js"data-settings-js="settings-4313503d2e1961c2.js"><scriptsrc="../static.files/storage-118b08c4c78b968e.js"></script><scriptdefersrc="../crates.js"></script><scriptdefersrc="../static.files/main-20a3ad099b048cf2.js"></script><noscript><linkrel="stylesheet"href="../static.files/noscript-df360f571f6edeae.css"></noscript><linkrel="alternate icon"type="image/png"href="../static.files/favicon-32x32-422f7d1d52889060.png"><linkrel="icon"type="image/svg+xml"href="../static.files/favicon-2c020d218678b618.svg"></head><bodyclass="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle"title="show sidebar"></button></nav><navclass="sidebar"><divclass="sidebar-crate"><h2><ahref="../indexmap/index.html">indexmap</a><spanclass="version">2.3.0</span></h2></div><divclass="sidebar-elems"><ulclass="block"><li><aid="all-types"href="all.html">All Items</a></li></ul><section><ulclass="block"><li><ahref="#reexports">Re-exports</a></li><li><ahref="#modules">Modules</a></li><li><ahref="#macros">Macros</a></li><li><ahref="#structs">Structs</a></li><li><ahref="#traits">Traits</a></li></ul></section></div></nav><divclass="sidebar-resizer"></div><main><divclass="width-limiter"><rustdoc-search></rustdoc-search><sectionid="main-content"class="content"><divclass="main-heading"><h1>Crate <aclass="mod"href="#">indexmap</a><buttonid="copy-path"title="Copy item path to clipboard">Copy item path</button></h1><spanclass="out-of-band"><aclass="src"href="../src/indexmap/lib.rs.html#2-274">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p><ahref="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> is a hash table where the iteration order of the key-value
pairs is independent of the hash values of the keys.</p>
<p><ahref="set/struct.IndexSet.html"title="struct indexmap::set::IndexSet"><code>IndexSet</code></a> is a corresponding hash set using the same implementation and
<p><ahref="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <ahref="set/struct.IndexSet.html"title="struct indexmap::set::IndexSet"><code>IndexSet</code></a> are drop-in compatible with the std <code>HashMap</code>
and <code>HashSet</code>, but they also have some features of note:</p>
<ul>
<li>The ordering semantics (see their documentation for details)</li>
<li>Sorting methods and the <ahref="map/struct.IndexMap.html#method.pop"title="method indexmap::map::IndexMap::pop"><code>.pop()</code></a> methods.</li>
<li>The <ahref="trait.Equivalent.html"title="trait indexmap::Equivalent"><code>Equivalent</code></a> trait, which offers more flexible equality definitions
between borrowed and owned versions of keys.</li>
<li>The <ahref="map/trait.MutableKeys.html"title="trait indexmap::map::MutableKeys"><code>MutableKeys</code></a> trait, which gives opt-in mutable
<p>To reduce the amount of compiled code in the crate by default, certain
features are gated behind <ahref="https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section">feature flags</a>. These allow you to opt in to (or
out of) functionality. Below is a list of the features available in this
crate.</p>
<ul>
<li><code>std</code>: Enables features which require the Rust standard library. For more
information see the section on <ahref="#no-standard-library-targets"><code>no_std</code></a>.</li>
<li><code>rayon</code>: Enables parallel iteration and other parallel methods.</li>
<li><code>serde</code>: Adds implementations for <ahref="%60::serde::Serialize%60"><code>Serialize</code></a> and <ahref="%60::serde::Deserialize%60"><code>Deserialize</code></a>
to <ahref="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <ahref="set/struct.IndexSet.html"title="struct indexmap::set::IndexSet"><code>IndexSet</code></a>. Alternative implementations for
(de)serializing <ahref="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> as an ordered sequence are available in the
[<code>map::serde_seq</code>] module.</li>
<li><code>borsh</code>: Adds implementations for <ahref="%60::borsh::BorshSerialize%60"><code>BorshSerialize</code></a> and <ahref="%60::borsh::BorshDeserialize%60"><code>BorshDeserialize</code></a>
to <ahref="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <ahref="set/struct.IndexSet.html"title="struct indexmap::set::IndexSet"><code>IndexSet</code></a>.</li>
<li><code>arbitrary</code>: Adds implementations for the <ahref="%60::arbitrary::Arbitrary%60"><code>arbitrary::Arbitrary</code></a> trait
to <ahref="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <ahref="set/struct.IndexSet.html"title="struct indexmap::set::IndexSet"><code>IndexSet</code></a>.</li>
<li><code>quickcheck</code>: Adds implementations for the <ahref="%60::quickcheck::Arbitrary%60"><code>quickcheck::Arbitrary</code></a> trait
to <ahref="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <ahref="set/struct.IndexSet.html"title="struct indexmap::set::IndexSet"><code>IndexSet</code></a>.</li>
</ul>
<p><em>Note: only the <code>std</code> feature is enabled by default.</em></p>
<p><ahref="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <ahref="set/struct.IndexSet.html"title="struct indexmap::set::IndexSet"><code>IndexSet</code></a> have a default hasher type
<p>This crate supports being built without <code>std</code>, requiring <code>alloc</code> instead.
This is chosen by disabling the default “std” cargo feature, by adding
<code>default-features = false</code> to your dependency specification.</p>
<ul>
<li>Creating maps and sets using <ahref="map/struct.IndexMap.html#method.new"title="associated function indexmap::map::IndexMap::new"><code>new</code></a> and
<ahref="map/struct.IndexMap.html#method.with_capacity"title="associated function indexmap::map::IndexMap::with_capacity"><code>with_capacity</code></a> is unavailable without <code>std</code>.
Use methods <ahref="map/struct.IndexMap.html#method.default"title="associated function indexmap::map::IndexMap::default"><code>IndexMap::default</code></a>, <ahref="map/struct.IndexMap.html#method.with_hasher"title="associated function indexmap::map::IndexMap::with_hasher"><code>with_hasher</code></a>,
<ahref="map/struct.IndexMap.html#method.with_capacity_and_hasher"title="associated function indexmap::map::IndexMap::with_capacity_and_hasher"><code>with_capacity_and_hasher</code></a> instead.
A no-std compatible hasher will be needed as well, for example
from the crate <code>twox-hash</code>.</li>
<li>Macros <ahref="macro.indexmap.html"title="macro indexmap::indexmap"><code>indexmap!</code></a> and <ahref="macro.indexset.html"title="macro indexmap::indexset"><code>indexset!</code></a> are unavailable without <code>std</code>.</li>
</div></details><h2id="reexports"class="section-header">Re-exports<ahref="#reexports"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"id="reexport.IndexMap"><code>pub use crate::map::<aclass="struct"href="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap">IndexMap</a>;</code></div></li><li><divclass="item-name"id="reexport.IndexSet"><code>pub use crate::set::<aclass="struct"href="set/struct.IndexSet.html"title="struct indexmap::set::IndexSet">IndexSet</a>;</code></div></li></ul><h2id="modules"class="section-header">Modules<ahref="#modules"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="mod"href="map/index.html"title="mod indexmap::map">map</a></div><divclass="desc docblock-short"><ahref="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> is a hash table where the iteration order of the key-value
pairs is independent of the hash values of the keys.</div></li><li><divclass="item-name"><aclass="mod"href="set/index.html"title="mod indexmap::set">set</a></div><divclass="desc docblock-short">A hash set implemented using <ahref="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap"><code>IndexMap</code></a></div></li></ul><h2id="macros"class="section-header">Macros<ahref="#macros"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="macro"href="macro.indexmap.html"title="macro indexmap::indexmap">indexmap</a></div><divclass="desc docblock-short">Create an <ahref="map/struct.IndexMap.html"title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> from a list of key-value pairs</div></li><li><divclass="item-name"><aclass="macro"href="macro.indexset.html"title="macro indexmap::indexset">indexset</a></div><divclass="desc docblock-short">Create an <ahref="set/struct.IndexSet.html"title="struct indexmap::set::IndexSet"><code>IndexSet</code></a> from a list of values</div></li></ul><h2id="structs"class="section-header">Structs<ahref="#structs"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="struct"href="struct.TryReserveError.html"title="struct indexmap::TryReserveError">TryReserveError</a></div><divclass="desc docblock-short">The error type for <ahref="map/struct.IndexMap.html#method.try_reserve"title="method indexmap::map::IndexMap::try_reserve"><code>try_reserve</code></a> methods.</div></li></ul><h2id="traits"class="section-header">Traits<ahref="#traits"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="trait"href="trait.Equivalent.html"title="trait indexmap::Equivalent">Equivalent</a></div><divclass="desc docblock-short">Key equivalence trait.</div></li></ul></section></div></main></body></html>