blob: 6d63513db4a4cfb006fa164ac2bb8b9dc3f65751 [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="An LRU Cache"><meta name="keywords" content="rust, rustlang, rust-lang, LruCache"><title>LruCache in lru - 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 struct"><!--[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="../lru/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="../lru/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">LruCache</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.cap">cap</a></li><li><a href="#method.clear">clear</a></li><li><a href="#method.contains">contains</a></li><li><a href="#method.get">get</a></li><li><a href="#method.get_mut">get_mut</a></li><li><a href="#method.get_or_insert">get_or_insert</a></li><li><a href="#method.is_empty">is_empty</a></li><li><a href="#method.iter">iter</a></li><li><a href="#method.iter_mut">iter_mut</a></li><li><a href="#method.len">len</a></li><li><a href="#method.new">new</a></li><li><a href="#method.peek">peek</a></li><li><a href="#method.peek_lru">peek_lru</a></li><li><a href="#method.peek_mut">peek_mut</a></li><li><a href="#method.pop">pop</a></li><li><a href="#method.pop_entry">pop_entry</a></li><li><a href="#method.pop_lru">pop_lru</a></li><li><a href="#method.push">push</a></li><li><a href="#method.put">put</a></li><li><a href="#method.resize">resize</a></li><li><a href="#method.unbounded">unbounded</a></li><li><a href="#method.unbounded_with_hasher">unbounded_with_hasher</a></li><li><a href="#method.with_hasher">with_hasher</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Debug-for-LruCache%3CK%2C%20V%3E">Debug</a></li><li><a href="#impl-Drop-for-LruCache%3CK%2C%20V%2C%20S%3E">Drop</a></li><li><a href="#impl-IntoIterator-for-%26%27a%20LruCache%3CK%2C%20V%2C%20S%3E">IntoIterator</a></li><li><a href="#impl-IntoIterator-for-%26%27a%20mut%20LruCache%3CK%2C%20V%2C%20S%3E">IntoIterator</a></li><li><a href="#impl-IntoIterator-for-LruCache%3CK%2C%20V%3E">IntoIterator</a></li><li><a href="#impl-Send-for-LruCache%3CK%2C%20V%2C%20S%3E">Send</a></li><li><a href="#impl-Sync-for-LruCache%3CK%2C%20V%2C%20S%3E">Sync</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-LruCache%3CK%2C%20V%2C%20S%3E">RefUnwindSafe</a></li><li><a href="#impl-Unpin-for-LruCache%3CK%2C%20V%2C%20S%3E">Unpin</a></li><li><a href="#impl-UnwindSafe-for-LruCache%3CK%2C%20V%2C%20S%3E">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-LruCache%3CK%2C%20V%2C%20S%3E">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-LruCache%3CK%2C%20V%2C%20S%3E">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-LruCache%3CK%2C%20V%2C%20S%3E">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-LruCache%3CK%2C%20V%2C%20S%3E">From&lt;T&gt;</a></li><li><a href="#impl-Into%3CU%3E-for-LruCache%3CK%2C%20V%2C%20S%3E">Into&lt;U&gt;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-LruCache%3CK%2C%20V%2C%20S%3E">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-LruCache%3CK%2C%20V%2C%20S%3E">TryInto&lt;U&gt;</a></li></ul></section><h2><a href="index.html">In lru</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">Struct <a href="index.html">lru</a>::<wbr><a class="struct" href="#">LruCache</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/lru/lib.rs.html#189-196">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 struct"><code>pub struct LruCache&lt;K, V, S&nbsp;=&nbsp;<a class="type" href="type.DefaultHasher.html" title="type lru::DefaultHasher">DefaultHasher</a>&gt; { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>An LRU Cache</p>
</div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-LruCache%3CK%2C%20V%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#198-222">source</a><a href="#impl-LruCache%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K:&nbsp;Hash + Eq, V&gt; <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V&gt;</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#207-209">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a>(cap: usize) -&gt; <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V&gt;</h4></section></summary><div class="docblock"><p>Creates a new LRU Cache that holds at most <code>cap</code> items.</p>
<h5 id="example"><a href="#example">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache: LruCache&lt;isize, <span class="kw-2">&amp;</span>str&gt; = LruCache::new(<span class="number">10</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.unbounded" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#219-221">source</a><h4 class="code-header">pub fn <a href="#method.unbounded" class="fnname">unbounded</a>() -&gt; <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V&gt;</h4></section></summary><div class="docblock"><p>Creates a new LRU Cache that never automatically evicts items.</p>
<h5 id="example-1"><a href="#example-1">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache: LruCache&lt;isize, <span class="kw-2">&amp;</span>str&gt; = LruCache::unbounded();</code></pre></div>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#224-908">source</a><a href="#impl-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;K:&nbsp;Hash + Eq, V, S:&nbsp;BuildHasher&gt; <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V, S&gt;</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_hasher" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#236-238">source</a><h4 class="code-header">pub fn <a href="#method.with_hasher" class="fnname">with_hasher</a>(cap: usize, hash_builder: S) -&gt; <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V, S&gt;</h4></section></summary><div class="docblock"><p>Creates a new LRU Cache that holds at most <code>cap</code> items and
uses the provided hash builder to hash keys.</p>
<h5 id="example-2"><a href="#example-2">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::{LruCache, DefaultHasher};
<span class="kw">let </span>s = DefaultHasher::default();
<span class="kw">let </span><span class="kw-2">mut </span>cache: LruCache&lt;isize, <span class="kw-2">&amp;</span>str&gt; = LruCache::with_hasher(<span class="number">10</span>, s);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.unbounded_with_hasher" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#251-253">source</a><h4 class="code-header">pub fn <a href="#method.unbounded_with_hasher" class="fnname">unbounded_with_hasher</a>(hash_builder: S) -&gt; <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V, S&gt;</h4></section></summary><div class="docblock"><p>Creates a new LRU Cache that never automatically evicts items and
uses the provided hash builder to hash keys.</p>
<h5 id="example-3"><a href="#example-3">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::{LruCache, DefaultHasher};
<span class="kw">let </span>s = DefaultHasher::default();
<span class="kw">let </span><span class="kw-2">mut </span>cache: LruCache&lt;isize, <span class="kw-2">&amp;</span>str&gt; = LruCache::unbounded_with_hasher(s);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.put" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#290-292">source</a><h4 class="code-header">pub fn <a href="#method.put" class="fnname">put</a>(&amp;mut self, k: K, v: V) -&gt; Option&lt;V&gt;</h4></section></summary><div class="docblock"><p>Puts a key-value pair into cache. If the key already exists in the cache, then it updates
the key’s value and returns the old value. Otherwise, <code>None</code> is returned.</p>
<h5 id="example-4"><a href="#example-4">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
<span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>));
<span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, cache.put(<span class="number">2</span>, <span class="string">&quot;b&quot;</span>));
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="string">&quot;b&quot;</span>), cache.put(<span class="number">2</span>, <span class="string">&quot;beta&quot;</span>));
<span class="macro">assert_eq!</span>(cache.get(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">&quot;a&quot;</span>));
<span class="macro">assert_eq!</span>(cache.get(<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="string">&quot;beta&quot;</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.push" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#317-319">source</a><h4 class="code-header">pub fn <a href="#method.push" class="fnname">push</a>(&amp;mut self, k: K, v: V) -&gt; Option&lt;(K, V)&gt;</h4></section></summary><div class="docblock"><p>Pushes a key-value pair into the cache. If an entry with key <code>k</code> already exists in
the cache or another cache entry is removed (due to the lru’s capacity),
then it returns the old entry’s key-value pair. Otherwise, returns <code>None</code>.</p>
<h5 id="example-5"><a href="#example-5">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
<span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, cache.push(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>));
<span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, cache.push(<span class="number">2</span>, <span class="string">&quot;b&quot;</span>));
<span class="comment">// This push call returns (2, &quot;b&quot;) because that was previously 2&#39;s entry in the cache.
</span><span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>((<span class="number">2</span>, <span class="string">&quot;b&quot;</span>)), cache.push(<span class="number">2</span>, <span class="string">&quot;beta&quot;</span>));
<span class="comment">// This push call returns (1, &quot;a&quot;) because the cache is at capacity and 1&#39;s entry was the lru entry.
</span><span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="string">&quot;a&quot;</span>)), cache.push(<span class="number">3</span>, <span class="string">&quot;alpha&quot;</span>));
<span class="macro">assert_eq!</span>(cache.get(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(cache.get(<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="string">&quot;beta&quot;</span>));
<span class="macro">assert_eq!</span>(cache.get(<span class="kw-2">&amp;</span><span class="number">3</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">&quot;alpha&quot;</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#401-416">source</a><h4 class="code-header">pub fn <a href="#method.get" class="fnname">get</a>&lt;'a, Q&gt;(&amp;'a mut self, k: &amp;Q) -&gt; Option&lt;&amp;'a V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;KeyRef&lt;K&gt;: Borrow&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: Hash + Eq + ?Sized,</span></h4></section></summary><div class="docblock"><p>Returns a reference to the value of the key in the cache or <code>None</code> if it is not
present in the cache. Moves the key to the head of the LRU list if it exists.</p>
<h5 id="example-6"><a href="#example-6">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;b&quot;</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;c&quot;</span>);
cache.put(<span class="number">3</span>, <span class="string">&quot;d&quot;</span>);
<span class="macro">assert_eq!</span>(cache.get(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(cache.get(<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="string">&quot;c&quot;</span>));
<span class="macro">assert_eq!</span>(cache.get(<span class="kw-2">&amp;</span><span class="number">3</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">&quot;d&quot;</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_mut" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#436-451">source</a><h4 class="code-header">pub fn <a href="#method.get_mut" class="fnname">get_mut</a>&lt;'a, Q&gt;(&amp;'a mut self, k: &amp;Q) -&gt; Option&lt;&amp;'a mut V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;KeyRef&lt;K&gt;: Borrow&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: Hash + Eq + ?Sized,</span></h4></section></summary><div class="docblock"><p>Returns a mutable reference to the value of the key in the cache or <code>None</code> if it
is not present in the cache. Moves the key to the head of the LRU list if it exists.</p>
<h5 id="example-7"><a href="#example-7">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
cache.put(<span class="string">&quot;apple&quot;</span>, <span class="number">8</span>);
cache.put(<span class="string">&quot;banana&quot;</span>, <span class="number">4</span>);
cache.put(<span class="string">&quot;banana&quot;</span>, <span class="number">6</span>);
cache.put(<span class="string">&quot;pear&quot;</span>, <span class="number">2</span>);
<span class="macro">assert_eq!</span>(cache.get_mut(<span class="kw-2">&amp;</span><span class="string">&quot;apple&quot;</span>), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(cache.get_mut(<span class="kw-2">&amp;</span><span class="string">&quot;banana&quot;</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;mut </span><span class="number">6</span>));
<span class="macro">assert_eq!</span>(cache.get_mut(<span class="kw-2">&amp;</span><span class="string">&quot;pear&quot;</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;mut </span><span class="number">2</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_or_insert" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#477-504">source</a><h4 class="code-header">pub fn <a href="#method.get_or_insert" class="fnname">get_or_insert</a>&lt;'a, F&gt;(&amp;'a mut self, k: K, f: F) -&gt; Option&lt;&amp;'a V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: FnOnce() -&gt; V,</span></h4></section></summary><div class="docblock"><p>Returns a reference to the value of the key in the cache if it is
present in the cache and moves the key to the head of the LRU list.
If the key does not exist the provided <code>FnOnce</code> is used to populate
the list and a reference is returned.</p>
<p>This method will only return <code>None</code> when the capacity of the cache is 0 and no entries
can be populated.</p>
<h5 id="example-8"><a href="#example-8">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;b&quot;</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;c&quot;</span>);
cache.put(<span class="number">3</span>, <span class="string">&quot;d&quot;</span>);
<span class="macro">assert_eq!</span>(cache.get_or_insert(<span class="number">2</span>, ||<span class="string">&quot;a&quot;</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">&quot;c&quot;</span>));
<span class="macro">assert_eq!</span>(cache.get_or_insert(<span class="number">3</span>, ||<span class="string">&quot;a&quot;</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">&quot;d&quot;</span>));
<span class="macro">assert_eq!</span>(cache.get_or_insert(<span class="number">1</span>, ||<span class="string">&quot;a&quot;</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">&quot;a&quot;</span>));
<span class="macro">assert_eq!</span>(cache.get_or_insert(<span class="number">1</span>, ||<span class="string">&quot;b&quot;</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">&quot;a&quot;</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peek" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#522-530">source</a><h4 class="code-header">pub fn <a href="#method.peek" class="fnname">peek</a>&lt;'a, Q&gt;(&amp;'a self, k: &amp;Q) -&gt; Option&lt;&amp;'a V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;KeyRef&lt;K&gt;: Borrow&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: Hash + Eq + ?Sized,</span></h4></section></summary><div class="docblock"><p>Returns a reference to the value corresponding to the key in the cache or <code>None</code> if it is
not present in the cache. Unlike <code>get</code>, <code>peek</code> does not update the LRU list so the key’s
position will be unchanged.</p>
<h5 id="example-9"><a href="#example-9">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;b&quot;</span>);
<span class="macro">assert_eq!</span>(cache.peek(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">&quot;a&quot;</span>));
<span class="macro">assert_eq!</span>(cache.peek(<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="string">&quot;b&quot;</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peek_mut" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#548-557">source</a><h4 class="code-header">pub fn <a href="#method.peek_mut" class="fnname">peek_mut</a>&lt;'a, Q&gt;(&amp;'a mut self, k: &amp;Q) -&gt; Option&lt;&amp;'a mut V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;KeyRef&lt;K&gt;: Borrow&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: Hash + Eq + ?Sized,</span></h4></section></summary><div class="docblock"><p>Returns a mutable reference to the value corresponding to the key in the cache or <code>None</code>
if it is not present in the cache. Unlike <code>get_mut</code>, <code>peek_mut</code> does not update the LRU
list so the key’s position will be unchanged.</p>
<h5 id="example-10"><a href="#example-10">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;b&quot;</span>);
<span class="macro">assert_eq!</span>(cache.peek_mut(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;mut </span><span class="string">&quot;a&quot;</span>));
<span class="macro">assert_eq!</span>(cache.peek_mut(<span class="kw-2">&amp;</span><span class="number">2</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;mut </span><span class="string">&quot;b&quot;</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peek_lru" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#574-587">source</a><h4 class="code-header">pub fn <a href="#method.peek_lru" class="fnname">peek_lru</a>&lt;'a&gt;(&amp;self) -&gt; Option&lt;(&amp;'a K, &amp;'a V)&gt;</h4></section></summary><div class="docblock"><p>Returns the value corresponding to the least recently used item or <code>None</code> if the
cache is empty. Like <code>peek</code>, <code>peek_lru</code> does not update the LRU list so the item’s
position will be unchanged.</p>
<h5 id="example-11"><a href="#example-11">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;b&quot;</span>);
<span class="macro">assert_eq!</span>(cache.peek_lru(), <span class="prelude-val">Some</span>((<span class="kw-2">&amp;</span><span class="number">1</span>, <span class="kw-2">&amp;</span><span class="string">&quot;a&quot;</span>)));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.contains" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#606-612">source</a><h4 class="code-header">pub fn <a href="#method.contains" class="fnname">contains</a>&lt;Q&gt;(&amp;self, k: &amp;Q) -&gt; bool<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;KeyRef&lt;K&gt;: Borrow&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: Hash + Eq + ?Sized,</span></h4></section></summary><div class="docblock"><p>Returns a bool indicating whether the given key is in the cache. Does not update the
LRU list.</p>
<h5 id="example-12"><a href="#example-12">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;b&quot;</span>);
cache.put(<span class="number">3</span>, <span class="string">&quot;c&quot;</span>);
<span class="macro">assert!</span>(!cache.contains(<span class="kw-2">&amp;</span><span class="number">1</span>));
<span class="macro">assert!</span>(cache.contains(<span class="kw-2">&amp;</span><span class="number">2</span>));
<span class="macro">assert!</span>(cache.contains(<span class="kw-2">&amp;</span><span class="number">3</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.pop" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#630-646">source</a><h4 class="code-header">pub fn <a href="#method.pop" class="fnname">pop</a>&lt;Q&gt;(&amp;mut self, k: &amp;Q) -&gt; Option&lt;V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;KeyRef&lt;K&gt;: Borrow&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: Hash + Eq + ?Sized,</span></h4></section></summary><div class="docblock"><p>Removes and returns the value corresponding to the key from the cache or
<code>None</code> if it does not exist.</p>
<h5 id="example-13"><a href="#example-13">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;a&quot;</span>);
<span class="macro">assert_eq!</span>(cache.pop(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(cache.pop(<span class="kw-2">&amp;</span><span class="number">2</span>), <span class="prelude-val">Some</span>(<span class="string">&quot;a&quot;</span>));
<span class="macro">assert_eq!</span>(cache.pop(<span class="kw-2">&amp;</span><span class="number">2</span>), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">0</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.pop_entry" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#666-679">source</a><h4 class="code-header">pub fn <a href="#method.pop_entry" class="fnname">pop_entry</a>&lt;Q&gt;(&amp;mut self, k: &amp;Q) -&gt; Option&lt;(K, V)&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;KeyRef&lt;K&gt;: Borrow&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: Hash + Eq + ?Sized,</span></h4></section></summary><div class="docblock"><p>Removes and returns the key and the value corresponding to the key from the cache or
<code>None</code> if it does not exist.</p>
<h5 id="example-14"><a href="#example-14">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;a&quot;</span>);
<span class="macro">assert_eq!</span>(cache.pop(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="string">&quot;a&quot;</span>));
<span class="macro">assert_eq!</span>(cache.pop_entry(<span class="kw-2">&amp;</span><span class="number">2</span>), <span class="prelude-val">Some</span>((<span class="number">2</span>, <span class="string">&quot;a&quot;</span>)));
<span class="macro">assert_eq!</span>(cache.pop(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(cache.pop_entry(<span class="kw-2">&amp;</span><span class="number">2</span>), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">0</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.pop_lru" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#700-706">source</a><h4 class="code-header">pub fn <a href="#method.pop_lru" class="fnname">pop_lru</a>(&amp;mut self) -&gt; Option&lt;(K, V)&gt;</h4></section></summary><div class="docblock"><p>Removes and returns the key and value corresponding to the least recently
used item or <code>None</code> if the cache is empty.</p>
<h5 id="example-15"><a href="#example-15">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;a&quot;</span>);
cache.put(<span class="number">3</span>, <span class="string">&quot;b&quot;</span>);
cache.put(<span class="number">4</span>, <span class="string">&quot;c&quot;</span>);
cache.get(<span class="kw-2">&amp;</span><span class="number">3</span>);
<span class="macro">assert_eq!</span>(cache.pop_lru(), <span class="prelude-val">Some</span>((<span class="number">4</span>, <span class="string">&quot;c&quot;</span>)));
<span class="macro">assert_eq!</span>(cache.pop_lru(), <span class="prelude-val">Some</span>((<span class="number">3</span>, <span class="string">&quot;b&quot;</span>)));
<span class="macro">assert_eq!</span>(cache.pop_lru(), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">0</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.len" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#726-728">source</a><h4 class="code-header">pub fn <a href="#method.len" class="fnname">len</a>(&amp;self) -&gt; usize</h4></section></summary><div class="docblock"><p>Returns the number of key-value pairs that are currently in the the cache.</p>
<h5 id="example-16"><a href="#example-16">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">0</span>);
cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>);
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">1</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;b&quot;</span>);
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">2</span>);
cache.put(<span class="number">3</span>, <span class="string">&quot;c&quot;</span>);
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">2</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_empty" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#742-744">source</a><h4 class="code-header">pub fn <a href="#method.is_empty" class="fnname">is_empty</a>(&amp;self) -&gt; bool</h4></section></summary><div class="docblock"><p>Returns a bool indicating whether the cache is empty or not.</p>
<h5 id="example-17"><a href="#example-17">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">2</span>);
<span class="macro">assert!</span>(cache.is_empty());
cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>);
<span class="macro">assert!</span>(!cache.is_empty());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cap" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#755-757">source</a><h4 class="code-header">pub fn <a href="#method.cap" class="fnname">cap</a>(&amp;self) -&gt; usize</h4></section></summary><div class="docblock"><p>Returns the maximum number of key-value pairs the cache can hold.</p>
<h5 id="example-18"><a href="#example-18">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache: LruCache&lt;isize, <span class="kw-2">&amp;</span>str&gt; = LruCache::new(<span class="number">2</span>);
<span class="macro">assert_eq!</span>(cache.cap(), <span class="number">2</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.resize" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#780-792">source</a><h4 class="code-header">pub fn <a href="#method.resize" class="fnname">resize</a>(&amp;mut self, cap: usize)</h4></section></summary><div class="docblock"><p>Resizes the cache. If the new capacity is smaller than the size of the current
cache any entries past the new capacity are discarded.</p>
<h5 id="example-19"><a href="#example-19">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache: LruCache&lt;isize, <span class="kw-2">&amp;</span>str&gt; = LruCache::new(<span class="number">2</span>);
cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;b&quot;</span>);
cache.resize(<span class="number">4</span>);
cache.put(<span class="number">3</span>, <span class="string">&quot;c&quot;</span>);
cache.put(<span class="number">4</span>, <span class="string">&quot;d&quot;</span>);
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">4</span>);
<span class="macro">assert_eq!</span>(cache.get(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">&quot;a&quot;</span>));
<span class="macro">assert_eq!</span>(cache.get(<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="string">&quot;b&quot;</span>));
<span class="macro">assert_eq!</span>(cache.get(<span class="kw-2">&amp;</span><span class="number">3</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">&quot;c&quot;</span>));
<span class="macro">assert_eq!</span>(cache.get(<span class="kw-2">&amp;</span><span class="number">4</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="string">&quot;d&quot;</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clear" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#812-814">source</a><h4 class="code-header">pub fn <a href="#method.clear" class="fnname">clear</a>(&amp;mut self)</h4></section></summary><div class="docblock"><p>Clears the contents of the cache.</p>
<h5 id="example-20"><a href="#example-20">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache: LruCache&lt;isize, <span class="kw-2">&amp;</span>str&gt; = LruCache::new(<span class="number">2</span>);
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">0</span>);
cache.put(<span class="number">1</span>, <span class="string">&quot;a&quot;</span>);
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">1</span>);
cache.put(<span class="number">2</span>, <span class="string">&quot;b&quot;</span>);
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">2</span>);
cache.clear();
<span class="macro">assert_eq!</span>(cache.len(), <span class="number">0</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.iter" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#833-840">source</a><h4 class="code-header">pub fn <a href="#method.iter" class="fnname">iter</a>(&amp;self) -&gt; <a class="struct" href="struct.Iter.html" title="struct lru::Iter">Iter</a>&lt;'_, K, V&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.Iter.html" title="struct lru::Iter">Iter</a>&lt;'a, K, V&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;'a, K, V&gt; Iterator for <a class="struct" href="struct.Iter.html" title="struct lru::Iter">Iter</a>&lt;'a, K, V&gt;</span><span class="where fmt-newline"> type <a class="associatedtype">Item</a> = (&amp;'a K, &amp;'a V);</span></code></span></span></span></span></h4></section></summary><div class="docblock"><p>An iterator visiting all entries in most-recently used order. The iterator element type is
<code>(&amp;K, &amp;V)</code>.</p>
<h5 id="examples"><a href="#examples">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">3</span>);
cache.put(<span class="string">&quot;a&quot;</span>, <span class="number">1</span>);
cache.put(<span class="string">&quot;b&quot;</span>, <span class="number">2</span>);
cache.put(<span class="string">&quot;c&quot;</span>, <span class="number">3</span>);
<span class="kw">for </span>(key, val) <span class="kw">in </span>cache.iter() {
<span class="macro">println!</span>(<span class="string">&quot;key: {} val: {}&quot;</span>, key, val);
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.iter_mut" class="method has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#868-875">source</a><h4 class="code-header">pub fn <a href="#method.iter_mut" class="fnname">iter_mut</a>(&amp;mut self) -&gt; <a class="struct" href="struct.IterMut.html" title="struct lru::IterMut">IterMut</a>&lt;'_, K, V&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.IterMut.html" title="struct lru::IterMut">IterMut</a>&lt;'a, K, V&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;'a, K, V&gt; Iterator for <a class="struct" href="struct.IterMut.html" title="struct lru::IterMut">IterMut</a>&lt;'a, K, V&gt;</span><span class="where fmt-newline"> type <a class="associatedtype">Item</a> = (&amp;'a K, &amp;'a mut V);</span></code></span></span></span></span></h4></section></summary><div class="docblock"><p>An iterator visiting all entries in most-recently-used order, giving a mutable reference on
V. The iterator element type is <code>(&amp;K, &amp;mut V)</code>.</p>
<h5 id="examples-1"><a href="#examples-1">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>lru::LruCache;
<span class="kw">struct </span>HddBlock {
dirty: bool,
data: [u8; <span class="number">512</span>]
}
<span class="kw">let </span><span class="kw-2">mut </span>cache = LruCache::new(<span class="number">3</span>);
cache.put(<span class="number">0</span>, HddBlock { dirty: <span class="bool-val">false</span>, data: [<span class="number">0x00</span>; <span class="number">512</span>]});
cache.put(<span class="number">1</span>, HddBlock { dirty: <span class="bool-val">true</span>, data: [<span class="number">0x55</span>; <span class="number">512</span>]});
cache.put(<span class="number">2</span>, HddBlock { dirty: <span class="bool-val">true</span>, data: [<span class="number">0x77</span>; <span class="number">512</span>]});
<span class="comment">// write dirty blocks to disk.
</span><span class="kw">for </span>(block_id, block) <span class="kw">in </span>cache.iter_mut() {
<span class="kw">if </span>block.dirty {
<span class="comment">// write block to disk
</span>block.dirty = <span class="bool-val">false
</span>}
}</code></pre></div>
</div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-LruCache%3CK%2C%20V%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#949-956">source</a><a href="#impl-Debug-for-LruCache%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K:&nbsp;Hash + Eq, V&gt; Debug for <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V&gt;</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#950-955">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a class="fnname">fmt</a>(&amp;self, f: &amp;mut Formatter&lt;'_&gt;) -&gt; Result</h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Drop-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#910-923">source</a><a href="#impl-Drop-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V, S&gt; Drop for <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V, S&gt;</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.drop" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#911-922">source</a><a href="#method.drop" class="anchor"></a><h4 class="code-header">fn <a class="fnname">drop</a>(&amp;mut self)</h4></section></summary><div class='docblock'>Executes the destructor for this type. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-IntoIterator-for-%26%27a%20LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#925-932">source</a><a href="#impl-IntoIterator-for-%26%27a%20LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;'a, K:&nbsp;Hash + Eq, V, S:&nbsp;BuildHasher&gt; IntoIterator for &amp;'a <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V, S&gt;</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Item" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Item" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Item</a> = (&amp;'a K, &amp;'a V)</h4></section></summary><div class='docblock'>The type of the elements being iterated over.</div></details><details class="rustdoc-toggle" open><summary><section id="associatedtype.IntoIter" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.IntoIter" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">IntoIter</a> = <a class="struct" href="struct.Iter.html" title="struct lru::Iter">Iter</a>&lt;'a, K, V&gt;</h4></section></summary><div class='docblock'>Which kind of iterator are we turning this into?</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into_iter" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#929-931">source</a><a href="#method.into_iter" class="anchor"></a><h4 class="code-header">fn <a class="fnname">into_iter</a>(self) -&gt; <a class="struct" href="struct.Iter.html" title="struct lru::Iter">Iter</a>&lt;'a, K, V&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.Iter.html" title="struct lru::Iter">Iter</a>&lt;'a, K, V&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;'a, K, V&gt; Iterator for <a class="struct" href="struct.Iter.html" title="struct lru::Iter">Iter</a>&lt;'a, K, V&gt;</span><span class="where fmt-newline"> type <a class="associatedtype">Item</a> = (&amp;'a K, &amp;'a V);</span></code></span></span></span></span></h4></section></summary><div class='docblock'>Creates an iterator from a value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-IntoIterator-for-%26%27a%20mut%20LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#934-941">source</a><a href="#impl-IntoIterator-for-%26%27a%20mut%20LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;'a, K:&nbsp;Hash + Eq, V, S:&nbsp;BuildHasher&gt; IntoIterator for &amp;'a mut <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V, S&gt;</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Item-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Item-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Item</a> = (&amp;'a K, &amp;'a mut V)</h4></section></summary><div class='docblock'>The type of the elements being iterated over.</div></details><details class="rustdoc-toggle" open><summary><section id="associatedtype.IntoIter-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.IntoIter-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">IntoIter</a> = <a class="struct" href="struct.IterMut.html" title="struct lru::IterMut">IterMut</a>&lt;'a, K, V&gt;</h4></section></summary><div class='docblock'>Which kind of iterator are we turning this into?</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into_iter-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#938-940">source</a><a href="#method.into_iter-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">into_iter</a>(self) -&gt; <a class="struct" href="struct.IterMut.html" title="struct lru::IterMut">IterMut</a>&lt;'a, K, V&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.IterMut.html" title="struct lru::IterMut">IterMut</a>&lt;'a, K, V&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;'a, K, V&gt; Iterator for <a class="struct" href="struct.IterMut.html" title="struct lru::IterMut">IterMut</a>&lt;'a, K, V&gt;</span><span class="where fmt-newline"> type <a class="associatedtype">Item</a> = (&amp;'a K, &amp;'a mut V);</span></code></span></span></span></span></h4></section></summary><div class='docblock'>Creates an iterator from a value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-IntoIterator-for-LruCache%3CK%2C%20V%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#1138-1145">source</a><a href="#impl-IntoIterator-for-LruCache%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K:&nbsp;Hash + Eq, V&gt; IntoIterator for <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V&gt;</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Item-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Item-2" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Item</a> = (K, V)</h4></section></summary><div class='docblock'>The type of the elements being iterated over.</div></details><details class="rustdoc-toggle" open><summary><section id="associatedtype.IntoIter-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.IntoIter-2" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">IntoIter</a> = <a class="struct" href="struct.IntoIter.html" title="struct lru::IntoIter">IntoIter</a>&lt;K, V&gt;</h4></section></summary><div class='docblock'>Which kind of iterator are we turning this into?</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into_iter-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#1142-1144">source</a><a href="#method.into_iter-2" class="anchor"></a><h4 class="code-header">fn <a class="fnname">into_iter</a>(self) -&gt; <a class="struct" href="struct.IntoIter.html" title="struct lru::IntoIter">IntoIter</a>&lt;K, V&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.IntoIter.html" title="struct lru::IntoIter">IntoIter</a>&lt;K, V&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;K, V&gt; Iterator for <a class="struct" href="struct.IntoIter.html" title="struct lru::IntoIter">IntoIter</a>&lt;K, V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Hash + Eq,</span></span><span class="where fmt-newline"> type <a class="associatedtype">Item</a> = (K, V);</span></code></span></span></span></span></h4></section></summary><div class='docblock'>Creates an iterator from a value. <a>Read more</a></div></details></div></details><section id="impl-Send-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#946">source</a><a href="#impl-Send-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;K:&nbsp;Send, V:&nbsp;Send, S:&nbsp;Send&gt; Send for <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V, S&gt;</h3></section><section id="impl-Sync-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/lru/lib.rs.html#947">source</a><a href="#impl-Sync-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;K:&nbsp;Sync, V:&nbsp;Sync, S:&nbsp;Sync&gt; Sync for <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V, S&gt;</h3></section></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"><section id="impl-RefUnwindSafe-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V, S&gt; RefUnwindSafe for <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V, S&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: RefUnwindSafe,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: RefUnwindSafe,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: RefUnwindSafe,</span></h3></section><section id="impl-Unpin-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a href="#impl-Unpin-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V, S&gt; Unpin for <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V, S&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: Unpin,</span></h3></section><section id="impl-UnwindSafe-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a href="#impl-UnwindSafe-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V, S&gt; UnwindSafe for <a class="struct" href="struct.LruCache.html" title="struct lru::LruCache">LruCache</a>&lt;K, V, S&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: UnwindSafe + RefUnwindSafe,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: UnwindSafe,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: UnwindSafe + RefUnwindSafe,</span></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a href="#impl-Any-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; Any for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a class="fnname">type_id</a>(&amp;self) -&gt; TypeId</h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a href="#impl-Borrow%3CT%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; Borrow&lt;T&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a class="fnname">borrow</a>(&amp;self) -&gt; &amp;T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a href="#impl-BorrowMut%3CT%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; BorrowMut&lt;T&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a class="fnname">borrow_mut</a>(&amp;mut self) -&gt; &amp;mut T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a href="#impl-From%3CT%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; From&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a href="#impl-Into%3CU%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; Into&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: From&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">into</a>(self) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code>[From]&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a href="#impl-TryFrom%3CU%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; TryFrom&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: Into&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = Infallible</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_from</a>(value: U) -&gt; Result&lt;T, &lt;T as TryFrom&lt;U&gt;&gt;::Error&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a href="#impl-TryInto%3CU%3E-for-LruCache%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; TryInto&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: TryFrom&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = &lt;U as TryFrom&lt;T&gt;&gt;::Error</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_into</a>(self) -&gt; Result&lt;U, &lt;U as TryFrom&lt;T&gt;&gt;::Error&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="lru" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>