blob: 13757d0c30c2d23a7dc6aaf3f85403d69d3b0001 [file] [log] [blame]
<!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="Opt-in mutable access to keys."><meta name="keywords" content="rust, rustlang, rust-lang, MutableKeys"><title>MutableKeys in indexmap::map - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[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">&#9776;</button><a class="sidebar-logo" href="../../indexmap/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../indexmap/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">MutableKeys</a></h2><div class="sidebar-elems"><section><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Key">Key</a></li><li><a href="#associatedtype.Value">Value</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.__private_marker">__private_marker</a></li><li><a href="#tymethod.get_full_mut2">get_full_mut2</a></li><li><a href="#tymethod.retain2">retain2</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In indexmap::map</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Trait <a href="../index.html">indexmap</a>::<wbr><a href="index.html">map</a>::<wbr><a class="trait" href="#">MutableKeys</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/indexmap/mutable_keys.rs.html#19-46">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust trait"><code>pub trait MutableKeys {
type <a href="#associatedtype.Key" class="associatedtype">Key</a>;
type <a href="#associatedtype.Value" class="associatedtype">Value</a>;
fn <a href="#tymethod.get_full_mut2" class="fnname">get_full_mut2</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;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Q<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, &amp;mut Self::<a class="associatedtype" href="trait.MutableKeys.html#associatedtype.Key" title="type indexmap::map::MutableKeys::Key">Key</a>, &amp;mut Self::<a class="associatedtype" href="trait.MutableKeys.html#associatedtype.Value" title="type indexmap::map::MutableKeys::Value">Value</a>)&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&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="../trait.Equivalent.html" title="trait indexmap::Equivalent">Equivalent</a>&lt;Self::<a class="associatedtype" href="trait.MutableKeys.html#associatedtype.Key" title="type indexmap::map::MutableKeys::Key">Key</a>&gt;</span>;
<span class="item-spacer"></span> fn <a href="#tymethod.retain2" class="fnname">retain2</a>&lt;F&gt;(&amp;mut self, keep: F)<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&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;mut Self::<a class="associatedtype" href="trait.MutableKeys.html#associatedtype.Key" title="type indexmap::map::MutableKeys::Key">Key</a>, &amp;mut Self::<a class="associatedtype" href="trait.MutableKeys.html#associatedtype.Value" title="type indexmap::map::MutableKeys::Value">Value</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.__private_marker" class="fnname">__private_marker</a>(&amp;self) -&gt; PrivateMarker;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Opt-in mutable access to keys.</p>
<p>These methods expose <code>&amp;mut K</code>, mutable references to the key as it is stored
in the map.
You are allowed to modify the keys in the hashmap <strong>if the modification
does not change the key’s hash and equality</strong>.</p>
<p>If keys are modified erroneously, you can no longer look them up.
This is sound (memory safe) but a logical error hazard (just like
implementing PartialEq, Eq, or Hash incorrectly would be).</p>
<p><code>use</code> this trait to enable its methods for <code>IndexMap</code>.</p>
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><section id="associatedtype.Key" class="method has-srclink"><a class="srclink rightside" href="../../src/indexmap/mutable_keys.rs.html#20">source</a><h4 class="code-header">type <a href="#associatedtype.Key" class="associatedtype">Key</a></h4></section><section id="associatedtype.Value" class="method has-srclink"><a class="srclink rightside" href="../../src/indexmap/mutable_keys.rs.html#21">source</a><h4 class="code-header">type <a href="#associatedtype.Value" class="associatedtype">Value</a></h4></section></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.get_full_mut2" class="method has-srclink"><a class="srclink rightside" href="../../src/indexmap/mutable_keys.rs.html#24-29">source</a><h4 class="code-header">fn <a href="#tymethod.get_full_mut2" class="fnname">get_full_mut2</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;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Q<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, &amp;mut Self::<a class="associatedtype" href="trait.MutableKeys.html#associatedtype.Key" title="type indexmap::map::MutableKeys::Key">Key</a>, &amp;mut Self::<a class="associatedtype" href="trait.MutableKeys.html#associatedtype.Value" title="type indexmap::map::MutableKeys::Value">Value</a>)&gt;<span class="where fmt-newline">where<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="../trait.Equivalent.html" title="trait indexmap::Equivalent">Equivalent</a>&lt;Self::<a class="associatedtype" href="trait.MutableKeys.html#associatedtype.Key" title="type indexmap::map::MutableKeys::Key">Key</a>&gt;,</span></h4></section></summary><div class="docblock"><p>Return item index, mutable reference to key and value</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.retain2" class="method has-srclink"><a class="srclink rightside" href="../../src/indexmap/mutable_keys.rs.html#38-40">source</a><h4 class="code-header">fn <a href="#tymethod.retain2" class="fnname">retain2</a>&lt;F&gt;(&amp;mut self, keep: 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;mut Self::<a class="associatedtype" href="trait.MutableKeys.html#associatedtype.Key" title="type indexmap::map::MutableKeys::Key">Key</a>, &amp;mut Self::<a class="associatedtype" href="trait.MutableKeys.html#associatedtype.Value" title="type indexmap::map::MutableKeys::Value">Value</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,</span></h4></section></summary><div class="docblock"><p>Scan through each key-value pair in the map and keep those where the
closure <code>keep</code> returns <code>true</code>.</p>
<p>The elements are visited in order, and remaining elements keep their
order.</p>
<p>Computes in <strong>O(n)</strong> time (average).</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.__private_marker" class="method has-srclink"><a class="srclink rightside" href="../../src/indexmap/mutable_keys.rs.html#45">source</a><h4 class="code-header">fn <a href="#tymethod.__private_marker" class="fnname">__private_marker</a>(&amp;self) -&gt; PrivateMarker</h4></section></summary><div class="docblock"><p>This method is not useful in itself – it is there to “seal” the trait
for external implementation, so that we can add methods without
causing breaking changes.</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-MutableKeys-for-IndexMap%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/indexmap/mutable_keys.rs.html#51-75">source</a><a href="#impl-MutableKeys-for-IndexMap%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V, S&gt; <a class="trait" href="trait.MutableKeys.html" title="trait indexmap::map::MutableKeys">MutableKeys</a> for <a class="struct" href="struct.IndexMap.html" title="struct indexmap::map::IndexMap">IndexMap</a>&lt;K, V, S&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: <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>,</span></h3></section></summary><div class="docblock"><p>Opt-in mutable access to keys.</p>
<p>See <a href="trait.MutableKeys.html"><code>MutableKeys</code></a> for more information.</p>
</div><div class="impl-items"><section id="associatedtype.Key-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Key-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Key" class="associatedtype">Key</a> = K</h4></section><section id="associatedtype.Value-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Value-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Value" class="associatedtype">Value</a> = V</h4></section></div></details></div><script src="../../implementors/indexmap/mutable_keys/trait.MutableKeys.js" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="indexmap" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>