328 lines
56 KiB
HTML
328 lines
56 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="API documentation for the Rust `LruCache` struct in crate `lru_cache`.">
|
|||
|
<meta name="keywords" content="rust, rustlang, rust-lang, LruCache">
|
|||
|
|
|||
|
<title>lru_cache::LruCache - Rust</title>
|
|||
|
|
|||
|
<link rel="stylesheet" type="text/css" href="../normalize.css">
|
|||
|
<link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle">
|
|||
|
|
|||
|
<link rel="stylesheet" type="text/css" href="../dark.css">
|
|||
|
<link rel="stylesheet" type="text/css" href="../main.css" id="themeStyle">
|
|||
|
<script src="../storage.js"></script>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</head>
|
|||
|
<body class="rustdoc struct">
|
|||
|
<!--[if lte IE 8]>
|
|||
|
<div class="warning">
|
|||
|
This old browser is unsupported and will most likely display funky
|
|||
|
things.
|
|||
|
</div>
|
|||
|
<![endif]-->
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<nav class="sidebar">
|
|||
|
<div class="sidebar-menu">☰</div>
|
|||
|
|
|||
|
<p class='location'>Struct LruCache</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.new">new</a><a href="#method.with_hasher">with_hasher</a><a href="#method.contains_key">contains_key</a><a href="#method.insert">insert</a><a href="#method.get_mut">get_mut</a><a href="#method.remove">remove</a><a href="#method.capacity">capacity</a><a href="#method.set_capacity">set_capacity</a><a href="#method.remove_lru">remove_lru</a><a href="#method.len">len</a><a href="#method.is_empty">is_empty</a><a href="#method.clear">clear</a><a href="#method.iter">iter</a><a href="#method.iter_mut">iter_mut</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Extend%3C(K%2C%20V)%3E">Extend<(K, V)></a><a href="#impl-Debug">Debug</a><a href="#impl-IntoIterator">IntoIterator</a></div></div><p class='location'><a href='index.html'>lru_cache</a></p><script>window.sidebarCurrent = {name: 'LruCache', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div>
|
|||
|
</nav>
|
|||
|
|
|||
|
<div class="theme-picker">
|
|||
|
<button id="theme-picker" aria-label="Pick another theme!">
|
|||
|
<img src="../brush.svg" width="18" alt="Pick another theme!">
|
|||
|
</button>
|
|||
|
<div id="theme-choices"></div>
|
|||
|
</div>
|
|||
|
<script src="../theme.js"></script>
|
|||
|
<nav class="sub">
|
|||
|
<form class="search-form js-only">
|
|||
|
<div class="search-container">
|
|||
|
<input class="search-input" name="search"
|
|||
|
autocomplete="off"
|
|||
|
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
|
|||
|
type="search">
|
|||
|
</div>
|
|||
|
</form>
|
|||
|
</nav>
|
|||
|
|
|||
|
<section id='main' class="content">
|
|||
|
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>lru_cache</a>::<wbr><a class="struct" href=''>LruCache</a></span><span class='out-of-band'><span id='render-detail'>
|
|||
|
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
|
|||
|
[<span class='inner'>−</span>]
|
|||
|
</a>
|
|||
|
</span><a class='srclink' href='../src/lru_cache/lib.rs.html#56-59' title='goto source code'>[src]</a></span></h1>
|
|||
|
<pre class='rust struct'>pub struct LruCache<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>, V, S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/std/collections/hash/map/struct.RandomState.html" title="struct std::collections::hash::map::RandomState">RandomState</a>> { /* fields omitted */ }</pre><div class='docblock'><p>An LRU cache.</p>
|
|||
|
</div>
|
|||
|
<h2 id='methods' class='small-section-header'>
|
|||
|
Methods<a href='#methods' class='anchor'></a>
|
|||
|
</h2>
|
|||
|
<h3 id='impl' class='impl'><span class='in-band'><code>impl<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>, V> <a class="struct" href="../lru_cache/struct.LruCache.html" title="struct lru_cache::LruCache">LruCache</a><K, V></code><a href='#impl' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#61-76' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><code>pub fn <a href='#method.new' class='fnname'>new</a>(capacity: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> Self</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#70-75' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Creates an empty cache that can hold at most <code>capacity</code> items.</p>
|
|||
|
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
|||
|
<pre class="rust rust-example-rendered">
|
|||
|
<span class="kw">use</span> <span class="ident">lru_cache</span>::<span class="ident">LruCache</span>;
|
|||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cache</span>: <span class="ident">LruCache</span><span class="op"><</span><span class="ident">i32</span>, <span class="kw-2">&</span><span class="ident">str</span><span class="op">></span> <span class="op">=</span> <span class="ident">LruCache</span>::<span class="ident">new</span>(<span class="number">10</span>);</pre>
|
|||
|
</div></div><h3 id='impl-1' class='impl'><span class='in-band'><code>impl<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>, V, S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>> <a class="struct" href="../lru_cache/struct.LruCache.html" title="struct lru_cache::LruCache">LruCache</a><K, V, S></code><a href='#impl-1' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#78-305' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.with_hasher' class="method"><span id='with_hasher.v' class='invisible'><code>pub fn <a href='#method.with_hasher' class='fnname'>with_hasher</a>(capacity: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, hash_builder: S) -> Self</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#80-82' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Creates an empty cache that can hold at most <code>capacity</code> items with the given hash builder.</p>
|
|||
|
</div><h4 id='method.contains_key' class="method"><span id='contains_key.v' class='invisible'><code>pub fn <a href='#method.contains_key' class='fnname'>contains_key</a><Q: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Q) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a> <span class="where fmt-newline">where<br> K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><Q>,<br> 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="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a>, </span></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#96-101' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Checks if the map contains the given key.</p>
|
|||
|
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
|||
|
<pre class="rust rust-example-rendered">
|
|||
|
<span class="kw">use</span> <span class="ident">lru_cache</span>::<span class="ident">LruCache</span>;
|
|||
|
|
|||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cache</span> <span class="op">=</span> <span class="ident">LruCache</span>::<span class="ident">new</span>(<span class="number">1</span>);
|
|||
|
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">1</span>, <span class="string">"a"</span>);
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">contains_key</span>(<span class="kw-2">&</span><span class="number">1</span>), <span class="bool-val">true</span>);</pre>
|
|||
|
</div><h4 id='method.insert' class="method"><span id='insert.v' class='invisible'><code>pub fn <a href='#method.insert' class='fnname'>insert</a>(&mut self, k: K, v: V) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><V></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#118-124' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Inserts a key-value pair into the cache. If the key already existed, the old value is
|
|||
|
returned.</p>
|
|||
|
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
|||
|
<pre class="rust rust-example-rendered">
|
|||
|
<span class="kw">use</span> <span class="ident">lru_cache</span>::<span class="ident">LruCache</span>;
|
|||
|
|
|||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cache</span> <span class="op">=</span> <span class="ident">LruCache</span>::<span class="ident">new</span>(<span class="number">2</span>);
|
|||
|
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">1</span>, <span class="string">"a"</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">2</span>, <span class="string">"b"</span>);
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="string">"a"</span>));
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">2</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="string">"b"</span>));</pre>
|
|||
|
</div><h4 id='method.get_mut' class="method"><span id='get_mut.v' class='invisible'><code>pub fn <a href='#method.get_mut' class='fnname'>get_mut</a><Q: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, k: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Q) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>V> <span class="where fmt-newline">where<br> K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><Q>,<br> 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="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a>, </span></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#144-149' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Returns a mutable reference to the value corresponding to the given key in the cache, if
|
|||
|
any.</p>
|
|||
|
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
|||
|
<pre class="rust rust-example-rendered">
|
|||
|
<span class="kw">use</span> <span class="ident">lru_cache</span>::<span class="ident">LruCache</span>;
|
|||
|
|
|||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cache</span> <span class="op">=</span> <span class="ident">LruCache</span>::<span class="ident">new</span>(<span class="number">2</span>);
|
|||
|
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">1</span>, <span class="string">"a"</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">2</span>, <span class="string">"b"</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">2</span>, <span class="string">"c"</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">3</span>, <span class="string">"d"</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">1</span>), <span class="prelude-val">None</span>);
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">2</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="string">"c"</span>));</pre>
|
|||
|
</div><h4 id='method.remove' class="method"><span id='remove.v' class='invisible'><code>pub fn <a href='#method.remove' class='fnname'>remove</a><Q: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, k: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Q) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><V> <span class="where fmt-newline">where<br> K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><Q>,<br> 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="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a>, </span></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#167-172' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Removes the given key from the cache and returns its corresponding value.</p>
|
|||
|
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
|||
|
<pre class="rust rust-example-rendered">
|
|||
|
<span class="kw">use</span> <span class="ident">lru_cache</span>::<span class="ident">LruCache</span>;
|
|||
|
|
|||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cache</span> <span class="op">=</span> <span class="ident">LruCache</span>::<span class="ident">new</span>(<span class="number">2</span>);
|
|||
|
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">2</span>, <span class="string">"a"</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">remove</span>(<span class="kw-2">&</span><span class="number">1</span>), <span class="prelude-val">None</span>);
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">remove</span>(<span class="kw-2">&</span><span class="number">2</span>), <span class="prelude-val">Some</span>(<span class="string">"a"</span>));
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">remove</span>(<span class="kw-2">&</span><span class="number">2</span>), <span class="prelude-val">None</span>);
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">len</span>(), <span class="number">0</span>);</pre>
|
|||
|
</div><h4 id='method.capacity' class="method"><span id='capacity.v' class='invisible'><code>pub fn <a href='#method.capacity' class='fnname'>capacity</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#183-185' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Returns the maximum number of key-value pairs the cache can hold.</p>
|
|||
|
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
|||
|
<pre class="rust rust-example-rendered">
|
|||
|
<span class="kw">use</span> <span class="ident">lru_cache</span>::<span class="ident">LruCache</span>;
|
|||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cache</span>: <span class="ident">LruCache</span><span class="op"><</span><span class="ident">i32</span>, <span class="kw-2">&</span><span class="ident">str</span><span class="op">></span> <span class="op">=</span> <span class="ident">LruCache</span>::<span class="ident">new</span>(<span class="number">2</span>);
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">capacity</span>(), <span class="number">2</span>);</pre>
|
|||
|
</div><h4 id='method.set_capacity' class="method"><span id='set_capacity.v' class='invisible'><code>pub fn <a href='#method.set_capacity' class='fnname'>set_capacity</a>(&mut self, capacity: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#219-224' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Sets the number of key-value pairs the cache can hold. Removes
|
|||
|
least-recently-used key-value pairs if necessary.</p>
|
|||
|
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
|||
|
<pre class="rust rust-example-rendered">
|
|||
|
<span class="kw">use</span> <span class="ident">lru_cache</span>::<span class="ident">LruCache</span>;
|
|||
|
|
|||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cache</span> <span class="op">=</span> <span class="ident">LruCache</span>::<span class="ident">new</span>(<span class="number">2</span>);
|
|||
|
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">1</span>, <span class="string">"a"</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">2</span>, <span class="string">"b"</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">3</span>, <span class="string">"c"</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">1</span>), <span class="prelude-val">None</span>);
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">2</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="string">"b"</span>));
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">3</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="string">"c"</span>));
|
|||
|
|
|||
|
<span class="ident">cache</span>.<span class="ident">set_capacity</span>(<span class="number">3</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">1</span>, <span class="string">"a"</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">2</span>, <span class="string">"b"</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="string">"a"</span>));
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">2</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="string">"b"</span>));
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">3</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="string">"c"</span>));
|
|||
|
|
|||
|
<span class="ident">cache</span>.<span class="ident">set_capacity</span>(<span class="number">1</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">1</span>), <span class="prelude-val">None</span>);
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">2</span>), <span class="prelude-val">None</span>);
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">3</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="string">"c"</span>));</pre>
|
|||
|
</div><h4 id='method.remove_lru' class="method"><span id='remove_lru.v' class='invisible'><code>pub fn <a href='#method.remove_lru' class='fnname'>remove_lru</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>K, V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#242-244' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Removes and returns the least recently used key-value pair as a tuple.</p>
|
|||
|
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
|||
|
<pre class="rust rust-example-rendered">
|
|||
|
<span class="kw">use</span> <span class="ident">lru_cache</span>::<span class="ident">LruCache</span>;
|
|||
|
|
|||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cache</span> <span class="op">=</span> <span class="ident">LruCache</span>::<span class="ident">new</span>(<span class="number">2</span>);
|
|||
|
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">1</span>, <span class="string">"a"</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">2</span>, <span class="string">"b"</span>);
|
|||
|
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">remove_lru</span>(), <span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="string">"a"</span>)));
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">len</span>(), <span class="number">1</span>);</pre>
|
|||
|
</div><h4 id='method.len' class="method"><span id='len.v' class='invisible'><code>pub fn <a href='#method.len' class='fnname'>len</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#247' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Returns the number of key-value pairs in the cache.</p>
|
|||
|
</div><h4 id='method.is_empty' class="method"><span id='is_empty.v' class='invisible'><code>pub fn <a href='#method.is_empty' class='fnname'>is_empty</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#250' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Returns <code>true</code> if the cache contains no key-value pairs.</p>
|
|||
|
</div><h4 id='method.clear' class="method"><span id='clear.v' class='invisible'><code>pub fn <a href='#method.clear' class='fnname'>clear</a>(&mut self)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#253' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Removes all key-value pairs from the cache.</p>
|
|||
|
</div><h4 id='method.iter' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../lru_cache/struct.Iter.html" title="struct lru_cache::Iter">Iter</a><'a, K, V></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../lru_cache/struct.Iter.html" title="struct lru_cache::Iter">Iter</a><'a, K, V></h3><code class="content"><span class="where fmt-newline">impl<'a, K, V> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../lru_cache/struct.Iter.html" title="struct lru_cache::Iter">Iter</a><'a, K, V></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a </a>K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a </a>V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>;</span></code></div></div><span id='iter.v' class='invisible'><code>pub fn <a href='#method.iter' class='fnname'>iter</a>(&self) -> <a class="struct" href="../lru_cache/struct.Iter.html" title="struct lru_cache::Iter">Iter</a><K, V></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#273' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Returns an iterator over the cache's key-value pairs in least- to most-recently-used order.</p>
|
|||
|
<p>Accessing the cache through the iterator does <em>not</em> affect the cache's LRU state.</p>
|
|||
|
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
|
|||
|
<pre class="rust rust-example-rendered">
|
|||
|
<span class="kw">use</span> <span class="ident">lru_cache</span>::<span class="ident">LruCache</span>;
|
|||
|
|
|||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cache</span> <span class="op">=</span> <span class="ident">LruCache</span>::<span class="ident">new</span>(<span class="number">2</span>);
|
|||
|
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">1</span>, <span class="number">10</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">2</span>, <span class="number">20</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">3</span>, <span class="number">30</span>);
|
|||
|
|
|||
|
<span class="kw">let</span> <span class="ident">kvs</span>: <span class="ident">Vec</span><span class="op"><</span>_<span class="op">></span> <span class="op">=</span> <span class="ident">cache</span>.<span class="ident">iter</span>().<span class="ident">collect</span>();
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">kvs</span>, [(<span class="kw-2">&</span><span class="number">2</span>, <span class="kw-2">&</span><span class="number">20</span>), (<span class="kw-2">&</span><span class="number">3</span>, <span class="kw-2">&</span><span class="number">30</span>)]);</pre>
|
|||
|
</div><h4 id='method.iter_mut' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../lru_cache/struct.IterMut.html" title="struct lru_cache::IterMut">IterMut</a><'a, K, V></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../lru_cache/struct.IterMut.html" title="struct lru_cache::IterMut">IterMut</a><'a, K, V></h3><code class="content"><span class="where fmt-newline">impl<'a, K, V> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../lru_cache/struct.IterMut.html" title="struct lru_cache::IterMut">IterMut</a><'a, K, V></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a </a>K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut </a>V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>;</span></code></div></div><span id='iter_mut.v' class='invisible'><code>pub fn <a href='#method.iter_mut' class='fnname'>iter_mut</a>(&mut self) -> <a class="struct" href="../lru_cache/struct.IterMut.html" title="struct lru_cache::IterMut">IterMut</a><K, V></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#304' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Returns an iterator over the cache's key-value pairs in least- to most-recently-used order,
|
|||
|
with mutable references to the values.</p>
|
|||
|
<p>Accessing the cache through the iterator does <em>not</em> affect the cache's LRU state.</p>
|
|||
|
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
|
|||
|
<pre class="rust rust-example-rendered">
|
|||
|
<span class="kw">use</span> <span class="ident">lru_cache</span>::<span class="ident">LruCache</span>;
|
|||
|
|
|||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">cache</span> <span class="op">=</span> <span class="ident">LruCache</span>::<span class="ident">new</span>(<span class="number">2</span>);
|
|||
|
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">1</span>, <span class="number">10</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">2</span>, <span class="number">20</span>);
|
|||
|
<span class="ident">cache</span>.<span class="ident">insert</span>(<span class="number">3</span>, <span class="number">30</span>);
|
|||
|
|
|||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">n</span> <span class="op">=</span> <span class="number">2</span>;
|
|||
|
|
|||
|
<span class="kw">for</span> (<span class="ident">k</span>, <span class="ident">v</span>) <span class="kw">in</span> <span class="ident">cache</span>.<span class="ident">iter_mut</span>() {
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">*</span><span class="ident">k</span>, <span class="ident">n</span>);
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">*</span><span class="ident">v</span>, <span class="ident">n</span> <span class="op">*</span> <span class="number">10</span>);
|
|||
|
<span class="kw-2">*</span><span class="ident">v</span> <span class="op">*=</span> <span class="number">10</span>;
|
|||
|
<span class="ident">n</span> <span class="op">+=</span> <span class="number">1</span>;
|
|||
|
}
|
|||
|
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">n</span>, <span class="number">4</span>);
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">2</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="number">200</span>));
|
|||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">cache</span>.<span class="ident">get_mut</span>(<span class="kw-2">&</span><span class="number">3</span>), <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="number">300</span>));</pre>
|
|||
|
</div></div>
|
|||
|
<h2 id='implementations' class='small-section-header'>
|
|||
|
Trait Implementations<a href='#implementations' class='anchor'></a>
|
|||
|
</h2>
|
|||
|
<h3 id='impl-Clone' class='impl'><span class='in-band'><code>impl<K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <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>, V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../lru_cache/struct.LruCache.html" title="struct lru_cache::LruCache">LruCache</a><K, V, S></code><a href='#impl-Clone' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#55' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.clone' class="method"><span id='clone.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&self) -> <a class="struct" href="../lru_cache/struct.LruCache.html" title="struct lru_cache::LruCache">LruCache</a><K, V, S></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#55' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
|||
|
</div><h4 id='method.clone_from' class="method"><span id='clone_from.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/clone.rs.html#112-114' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
|
|||
|
</div></div><h3 id='impl-Extend%3C(K%2C%20V)%3E' class='impl'><span class='in-band'><code>impl<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>, V, S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html" title="trait core::iter::traits::Extend">Extend</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>K, V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>> for <a class="struct" href="../lru_cache/struct.LruCache.html" title="struct lru_cache::LruCache">LruCache</a><K, V, S></code><a href='#impl-Extend%3C(K%2C%20V)%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#307-313' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.extend' class="method"><span id='extend.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html#tymethod.extend' class='fnname'>extend</a><I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a><Item = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>K, V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>>>(&mut self, iter: I)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#308-312' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Extends a collection with the contents of an iterator. <a href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html#tymethod.extend">Read more</a></p>
|
|||
|
</div></div><h3 id='impl-Debug' class='impl'><span class='in-band'><code>impl<K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <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>, V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>, S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../lru_cache/struct.LruCache.html" title="struct lru_cache::LruCache">LruCache</a><K, V, S></code><a href='#impl-Debug' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#315-319' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#316-318' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
|||
|
</div></div><h3 id='impl-IntoIterator' class='impl'><span class='in-band'><code>impl<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>, V, S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a> for <a class="struct" href="../lru_cache/struct.LruCache.html" title="struct lru_cache::LruCache">LruCache</a><K, V, S></code><a href='#impl-IntoIterator' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#321-328' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='associatedtype.Item' class="type"><span id='Item.t' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>K, V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span></h4>
|
|||
|
<div class='docblock'><p>The type of the elements being iterated over.</p>
|
|||
|
</div><h4 id='associatedtype.IntoIter' class="type"><span id='IntoIter.t' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter' class="type">IntoIter</a> = <a class="struct" href="../lru_cache/struct.IntoIter.html" title="struct lru_cache::IntoIter">IntoIter</a><K, V></code></span></h4>
|
|||
|
<div class='docblock'><p>Which kind of iterator are we turning this into?</p>
|
|||
|
</div><h4 id='method.into_iter' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../lru_cache/struct.IntoIter.html" title="struct lru_cache::IntoIter">IntoIter</a><K, V></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../lru_cache/struct.IntoIter.html" title="struct lru_cache::IntoIter">IntoIter</a><K, V></h3><code class="content"><span class="where fmt-newline">impl<K, V> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../lru_cache/struct.IntoIter.html" title="struct lru_cache::IntoIter">IntoIter</a><K, V></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>K, V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>;</span></code></div></div><span id='into_iter.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#tymethod.into_iter' class='fnname'>into_iter</a>(self) -> <a class="struct" href="../lru_cache/struct.IntoIter.html" title="struct lru_cache::IntoIter">IntoIter</a><K, V></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#325-327' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Creates an iterator from a value. <a href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#tymethod.into_iter">Read more</a></p>
|
|||
|
</div></div><h3 id='impl-IntoIterator-1' class='impl'><span class='in-band'><code>impl<'a, 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>, V, S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a> for &'a <a class="struct" href="../lru_cache/struct.LruCache.html" title="struct lru_cache::LruCache">LruCache</a><K, V, S></code><a href='#impl-IntoIterator-1' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#330-334' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='associatedtype.Item-1' class="type"><span id='Item.t-1' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a </a>K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a </a>V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span></h4>
|
|||
|
<div class='docblock'><p>The type of the elements being iterated over.</p>
|
|||
|
</div><h4 id='associatedtype.IntoIter-1' class="type"><span id='IntoIter.t-1' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter' class="type">IntoIter</a> = <a class="struct" href="../lru_cache/struct.Iter.html" title="struct lru_cache::Iter">Iter</a><'a, K, V></code></span></h4>
|
|||
|
<div class='docblock'><p>Which kind of iterator are we turning this into?</p>
|
|||
|
</div><h4 id='method.into_iter-1' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../lru_cache/struct.Iter.html" title="struct lru_cache::Iter">Iter</a><'a, K, V></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../lru_cache/struct.Iter.html" title="struct lru_cache::Iter">Iter</a><'a, K, V></h3><code class="content"><span class="where fmt-newline">impl<'a, K, V> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../lru_cache/struct.Iter.html" title="struct lru_cache::Iter">Iter</a><'a, K, V></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a </a>K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a </a>V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>;</span></code></div></div><span id='into_iter.v-1' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#tymethod.into_iter' class='fnname'>into_iter</a>(self) -> <a class="struct" href="../lru_cache/struct.Iter.html" title="struct lru_cache::Iter">Iter</a><'a, K, V></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#333' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Creates an iterator from a value. <a href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#tymethod.into_iter">Read more</a></p>
|
|||
|
</div></div><h3 id='impl-IntoIterator-2' class='impl'><span class='in-band'><code>impl<'a, 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>, V, S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a> for &'a mut <a class="struct" href="../lru_cache/struct.LruCache.html" title="struct lru_cache::LruCache">LruCache</a><K, V, S></code><a href='#impl-IntoIterator-2' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#336-340' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='associatedtype.Item-2' class="type"><span id='Item.t-2' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a </a>K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut </a>V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a></code></span></h4>
|
|||
|
<div class='docblock'><p>The type of the elements being iterated over.</p>
|
|||
|
</div><h4 id='associatedtype.IntoIter-2' class="type"><span id='IntoIter.t-2' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter' class="type">IntoIter</a> = <a class="struct" href="../lru_cache/struct.IterMut.html" title="struct lru_cache::IterMut">IterMut</a><'a, K, V></code></span></h4>
|
|||
|
<div class='docblock'><p>Which kind of iterator are we turning this into?</p>
|
|||
|
</div><h4 id='method.into_iter-2' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="struct" href="../lru_cache/struct.IterMut.html" title="struct lru_cache::IterMut">IterMut</a><'a, K, V></span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../lru_cache/struct.IterMut.html" title="struct lru_cache::IterMut">IterMut</a><'a, K, V></h3><code class="content"><span class="where fmt-newline">impl<'a, K, V> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../lru_cache/struct.IterMut.html" title="struct lru_cache::IterMut">IterMut</a><'a, K, V></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a </a>K, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut </a>V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>;</span></code></div></div><span id='into_iter.v-2' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#tymethod.into_iter' class='fnname'>into_iter</a>(self) -> <a class="struct" href="../lru_cache/struct.IterMut.html" title="struct lru_cache::IterMut">IterMut</a><'a, K, V></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/lru_cache/lib.rs.html#339' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Creates an iterator from a value. <a href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#tymethod.into_iter">Read more</a></p>
|
|||
|
</div></div></section>
|
|||
|
<section id='search' class="content hidden"></section>
|
|||
|
|
|||
|
<section class="footer"></section>
|
|||
|
|
|||
|
<aside id="help" class="hidden">
|
|||
|
<div>
|
|||
|
<h1 class="hidden">Help</h1>
|
|||
|
|
|||
|
<div class="shortcuts">
|
|||
|
<h2>Keyboard Shortcuts</h2>
|
|||
|
|
|||
|
<dl>
|
|||
|
<dt><kbd>?</kbd></dt>
|
|||
|
<dd>Show this help dialog</dd>
|
|||
|
<dt><kbd>S</kbd></dt>
|
|||
|
<dd>Focus the search field</dd>
|
|||
|
<dt><kbd>↑</kbd></dt>
|
|||
|
<dd>Move up in search results</dd>
|
|||
|
<dt><kbd>↓</kbd></dt>
|
|||
|
<dd>Move down in search results</dd>
|
|||
|
<dt><kbd>↹</kbd></dt>
|
|||
|
<dd>Switch tab</dd>
|
|||
|
<dt><kbd>⏎</kbd></dt>
|
|||
|
<dd>Go to active search result</dd>
|
|||
|
<dt><kbd>+</kbd></dt>
|
|||
|
<dd>Expand all sections</dd>
|
|||
|
<dt><kbd>-</kbd></dt>
|
|||
|
<dd>Collapse all sections</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="infos">
|
|||
|
<h2>Search Tricks</h2>
|
|||
|
|
|||
|
<p>
|
|||
|
Prefix searches with a type followed by a colon (e.g.
|
|||
|
<code>fn:</code>) to restrict the search to a given type.
|
|||
|
</p>
|
|||
|
|
|||
|
<p>
|
|||
|
Accepted types are: <code>fn</code>, <code>mod</code>,
|
|||
|
<code>struct</code>, <code>enum</code>,
|
|||
|
<code>trait</code>, <code>type</code>, <code>macro</code>,
|
|||
|
and <code>const</code>.
|
|||
|
</p>
|
|||
|
|
|||
|
<p>
|
|||
|
Search functions by type signature (e.g.
|
|||
|
<code>vec -> usize</code> or <code>* -> vec</code>)
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</aside>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<script>
|
|||
|
window.rootPath = "../";
|
|||
|
window.currentCrate = "lru_cache";
|
|||
|
</script>
|
|||
|
<script src="../main.js"></script>
|
|||
|
<script defer src="../search-index.js"></script>
|
|||
|
</body>
|
|||
|
</html>
|