mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-23 00:18:24 +00:00
80 lines
14 KiB
HTML
80 lines
14 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><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-ac92e1bbe349e143.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.76.0 (07dca489a 2024-02-04)" data-channel="1.76.0" data-search-js="search-2b6ce74ff89ae146.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-f2adc0d6ca4d09fb.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-305769736d49e732.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-feafe1bb7466e4bd.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><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">☰</button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../indexmap/index.html">indexmap</a><span class="version">2.2.5</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="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></section></div></nav><div class="sidebar-resizer"></div>
|
|||
|
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../indexmap/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><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"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../src/indexmap/lib.rs.html#2-275">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" 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><a href="set/struct.IndexSet.html" title="struct indexmap::set::IndexSet"><code>IndexSet</code></a> is a corresponding hash set using the same implementation and
|
|||
|
with similar properties.</p>
|
|||
|
<h4 id="highlights"><a href="#highlights">Highlights</a></h4>
|
|||
|
<p><a href="map/struct.IndexMap.html" title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <a href="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 <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="feature-flags"><a href="#feature-flags">Feature Flags</a></h4>
|
|||
|
<p>To reduce the amount of compiled code in the crate by default, certain
|
|||
|
features are gated behind <a href="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 <a href="#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 <a href="%60::serde::Serialize%60"><code>Serialize</code></a> and <a href="%60::serde::Deserialize%60"><code>Deserialize</code></a>
|
|||
|
to <a href="map/struct.IndexMap.html" title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <a href="set/struct.IndexSet.html" title="struct indexmap::set::IndexSet"><code>IndexSet</code></a>. Alternative implementations for
|
|||
|
(de)serializing <a href="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 <a href="%60::borsh::BorshSerialize%60"><code>BorshSerialize</code></a> and <a href="%60::borsh::BorshDeserialize%60"><code>BorshDeserialize</code></a>
|
|||
|
to <a href="map/struct.IndexMap.html" title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <a href="set/struct.IndexSet.html" title="struct indexmap::set::IndexSet"><code>IndexSet</code></a>.</li>
|
|||
|
<li><code>arbitrary</code>: Adds implementations for the <a href="%60::arbitrary::Arbitrary%60"><code>arbitrary::Arbitrary</code></a> trait
|
|||
|
to <a href="map/struct.IndexMap.html" title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <a href="set/struct.IndexSet.html" title="struct indexmap::set::IndexSet"><code>IndexSet</code></a>.</li>
|
|||
|
<li><code>quickcheck</code>: Adds implementations for the <a href="%60::quickcheck::Arbitrary%60"><code>quickcheck::Arbitrary</code></a> trait
|
|||
|
to <a href="map/struct.IndexMap.html" title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <a href="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>
|
|||
|
<h4 id="alternate-hashers"><a href="#alternate-hashers">Alternate Hashers</a></h4>
|
|||
|
<p><a href="map/struct.IndexMap.html" title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> and <a href="set/struct.IndexSet.html" title="struct indexmap::set::IndexSet"><code>IndexSet</code></a> have a default hasher type
|
|||
|
<a href="https://doc.rust-lang.org/1.76.0/std/hash/random/struct.RandomState.html" title="struct std::hash::random::RandomState"><code>S = RandomState</code></a>,
|
|||
|
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 href="#rust-version">Rust Version</a></h4>
|
|||
|
<p>This version of indexmap requires Rust 1.63 or later.</p>
|
|||
|
<p>The indexmap 2.x release series will use a carefully considered version
|
|||
|
upgrade policy, where in a later 2.x version, we will raise the minimum
|
|||
|
required Rust version.</p>
|
|||
|
<h3 id="no-standard-library-targets"><a href="#no-standard-library-targets">No Standard Library Targets</a></h3>
|
|||
|
<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 <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>.
|
|||
|
Use methods <a href="map/struct.IndexMap.html#method.default" title="associated function indexmap::map::IndexMap::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"><a href="#reexports">Re-exports</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"><a href="#modules">Modules</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"><a href="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><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 <a href="map/struct.IndexMap.html" title="struct indexmap::map::IndexMap"><code>IndexMap</code></a></div></li></ul><h2 id="macros" class="section-header"><a href="#macros">Macros</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 <a href="map/struct.IndexMap.html" title="struct indexmap::map::IndexMap"><code>IndexMap</code></a> 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 <a href="set/struct.IndexSet.html" title="struct indexmap::set::IndexSet"><code>IndexSet</code></a> from a list of values</div></li></ul><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.TryReserveError.html" title="struct indexmap::TryReserveError">TryReserveError</a></div><div class="desc docblock-short">The error type for <a href="map/struct.IndexMap.html#method.try_reserve" title="method indexmap::map::IndexMap::try_reserve"><code>try_reserve</code></a> methods.</div></li></ul><h2 id="traits" class="section-header"><a href="#traits">Traits</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>
|