mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-26 05:29:38 +01:00
58 lines
No EOL
9.8 KiB
HTML
58 lines
No EOL
9.8 KiB
HTML
<!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="`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><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-492a78a4a87dcc01.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="indexmap" data-themes="" data-resource-suffix="" data-rustdoc-version="1.82.0 (f6e511eec 2024-10-15)" data-channel="1.82.0" data-search-js="search-a99f1315e7cc5121.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-921df33f47b8780c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-3b12f09e550e0385.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../indexmap/index.html">indexmap</a><span class="version">1.9.3</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li><li><a href="#traits">Traits</a></li></ul></section></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">indexmap</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/indexmap/lib.rs.html#2-194">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><a href="map/struct.IndexMap.html"><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><a href="set/struct.IndexSet.html"><code>IndexSet</code></a> is a corresponding hash set using the same implementation and
|
|
with similar properties.</p>
|
|
<h4 id="feature-highlights"><a class="doc-anchor" href="#feature-highlights">§</a>Feature Highlights</h4>
|
|
<p><a href="map/struct.IndexMap.html"><code>IndexMap</code></a> and <a href="set/struct.IndexSet.html"><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 <a href="map/struct.IndexMap.html#method.pop" title="method indexmap::map::IndexMap::pop"><code>.pop()</code></a> methods.</li>
|
|
<li>The <a href="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 <a href="map/trait.MutableKeys.html" title="trait indexmap::map::MutableKeys"><code>MutableKeys</code></a> trait, which gives opt-in mutable
|
|
access to hash map keys.</li>
|
|
</ul>
|
|
<h4 id="alternate-hashers"><a class="doc-anchor" href="#alternate-hashers">§</a>Alternate Hashers</h4>
|
|
<p><a href="map/struct.IndexMap.html"><code>IndexMap</code></a> and <a href="set/struct.IndexSet.html"><code>IndexSet</code></a> have a default hasher type <code>S = RandomState</code>,
|
|
just like the standard <code>HashMap</code> and <code>HashSet</code>, which is resistant to
|
|
HashDoS attacks but not the most performant. Type aliases can make it easier
|
|
to use alternate hashers:</p>
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>fnv::FnvBuildHasher;
|
|
<span class="kw">use </span>fxhash::FxBuildHasher;
|
|
<span class="kw">use </span>indexmap::{IndexMap, IndexSet};
|
|
|
|
<span class="kw">type </span>FnvIndexMap<K, V> = IndexMap<K, V, FnvBuildHasher>;
|
|
<span class="kw">type </span>FnvIndexSet<T> = IndexSet<T, FnvBuildHasher>;
|
|
|
|
<span class="kw">type </span>FxIndexMap<K, V> = IndexMap<K, V, FxBuildHasher>;
|
|
<span class="kw">type </span>FxIndexSet<T> = IndexSet<T, FxBuildHasher>;
|
|
|
|
<span class="kw">let </span>std: IndexSet<i32> = (<span class="number">0</span>..<span class="number">100</span>).collect();
|
|
<span class="kw">let </span>fnv: FnvIndexSet<i32> = (<span class="number">0</span>..<span class="number">100</span>).collect();
|
|
<span class="kw">let </span>fx: FxIndexSet<i32> = (<span class="number">0</span>..<span class="number">100</span>).collect();
|
|
<span class="macro">assert_eq!</span>(std, fnv);
|
|
<span class="macro">assert_eq!</span>(std, fx);</code></pre></div>
|
|
<h4 id="rust-version"><a class="doc-anchor" href="#rust-version">§</a>Rust Version</h4>
|
|
<p>This version of indexmap requires Rust 1.56 or later.</p>
|
|
<p>The indexmap 1.x release series will use a carefully considered version
|
|
upgrade policy, where in a later 1.x version, we will raise the minimum
|
|
required Rust version.</p>
|
|
<h3 id="no-standard-library-targets"><a class="doc-anchor" href="#no-standard-library-targets">§</a>No Standard Library Targets</h3>
|
|
<p>This crate supports being built without <code>std</code>, requiring
|
|
<code>alloc</code> instead. This is enabled automatically when it is detected that
|
|
<code>std</code> is not available. There is no crate feature to enable/disable to
|
|
trigger this. It can be tested by building for a std-less target.</p>
|
|
<ul>
|
|
<li>Creating maps and sets using <a href="map/struct.IndexMap.html#method.new" title="associated function indexmap::map::IndexMap::new"><code>new</code></a> and
|
|
<a href="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>.<br />
|
|
Use methods <a href="map/struct.IndexMap.html#impl-Default"><code>IndexMap::default</code></a>,
|
|
<a href="map/struct.IndexMap.html#method.with_hasher" title="associated function indexmap::map::IndexMap::with_hasher"><code>with_hasher</code></a>,
|
|
<a href="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 <a href="macro.indexmap.html" title="macro indexmap::indexmap"><code>indexmap!</code></a> and <a href="macro.indexset.html" title="macro indexmap::indexset"><code>indexset!</code></a> are unavailable without <code>std</code>.</li>
|
|
</ul>
|
|
</div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name" id="reexport.IndexMap"><code>pub use crate::map::<a class="struct" href="map/struct.IndexMap.html" title="struct indexmap::map::IndexMap">IndexMap</a>;</code></div></li><li><div class="item-name" id="reexport.IndexSet"><code>pub use crate::set::<a class="struct" href="set/struct.IndexSet.html" title="struct indexmap::set::IndexSet">IndexSet</a>;</code></div></li></ul><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="map/index.html" title="mod indexmap::map">map</a></div><div class="desc docblock-short"><code>IndexMap</code> 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><div class="item-name"><a class="mod" href="set/index.html" title="mod indexmap::set">set</a></div><div class="desc docblock-short">A hash set implemented using <code>IndexMap</code></div></li></ul><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="macro" href="macro.indexmap.html" title="macro indexmap::indexmap">indexmap</a></div><div class="desc docblock-short">Create an <code>IndexMap</code> from a list of key-value pairs</div></li><li><div class="item-name"><a class="macro" href="macro.indexset.html" title="macro indexmap::indexset">indexset</a></div><div class="desc docblock-short">Create an <code>IndexSet</code> from a list of values</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.Equivalent.html" title="trait indexmap::Equivalent">Equivalent</a></div><div class="desc docblock-short">Key equivalence trait.</div></li></ul></section></div></main></body></html> |