<main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><divid="sidebar-button"tabindex="-1"><ahref="../sharded_slab/all.html"title="show sidebar"></a></div><inputclass="search-input"name="search"aria-label="Run search in the documentation"autocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"><divid="help-button"tabindex="-1"><ahref="../help.html"title="help">?</a></div><divid="settings-menu"tabindex="-1"><ahref="../settings.html"title="settings"><imgwidth="22"height="22"alt="Change settings"src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><sectionid="main-content"class="content"><divclass="main-heading"><h1>Struct <ahref="index.html">sharded_slab</a>::<wbr><aclass="struct"href="#">Slab</a><buttonid="copy-path"title="Copy item path to clipboard"><imgsrc="../static.files/clipboard-7571035ce49a181d.svg"width="19"height="18"alt="Copy item path"></button></h1><spanclass="out-of-band"><aclass="src"href="../src/sharded_slab/lib.rs.html#235-238">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><preclass="rust item-decl"><code>pub struct Slab<T, C: <aclass="trait"href="trait.Config.html"title="trait sharded_slab::Config">Config</a> = <aclass="struct"href="struct.DefaultConfig.html"title="struct sharded_slab::DefaultConfig">DefaultConfig</a>> { <spanclass="comment">/* private fields */</span> }</code></pre><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>A sharded slab.</p>
<p>See the <ahref="index.html"title="mod sharded_slab">crate-level documentation</a> for details on using this type.</p>
</div></details><h2id="implementations"class="section-header">Implementations<ahref="#implementations"class="anchor">§</a></h2><divid="implementations-list"><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Slab%3CT%3E"class="impl"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#375-389">source</a><ahref="#impl-Slab%3CT%3E"class="anchor">§</a><h3class="code-header">impl<T><aclass="struct"href="struct.Slab.html"title="struct sharded_slab::Slab">Slab</a><T></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.new"class="method"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#377-379">source</a><h4class="code-header">pub fn <ahref="#method.new"class="fn">new</a>() -> Self</h4></section></summary><divclass="docblock"><p>Returns a new slab with the default configuration parameters.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.new_with_config"class="method"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#382-388">source</a><h4class="code-header">pub fn <ahref="#method.new_with_config"class="fn">new_with_config</a><C: <aclass="trait"href="trait.Config.html"title="trait sharded_slab::Config">Config</a>>() -><aclass="struct"href="struct.Slab.html"title="struct sharded_slab::Slab">Slab</a><T, C></h4></section></summary><divclass="docblock"><p>Returns a new slab with the provided configuration parameters.</p>
</div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Slab%3CT,+C%3E"class="impl"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#391-763">source</a><ahref="#impl-Slab%3CT,+C%3E"class="anchor">§</a><h3class="code-header">impl<T, C: <aclass="trait"href="trait.Config.html"title="trait sharded_slab::Config">Config</a>><aclass="struct"href="struct.Slab.html"title="struct sharded_slab::Slab">Slab</a><T, C></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedconstant.USED_BITS"class="associatedconstant"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#403">source</a><h4class="code-header">pub const <ahref="#associatedconstant.USED_BITS"class="constant">USED_BITS</a>: <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.usize.html">usize</a> = C::USED_BITS</h4></section></summary><divclass="docblock"><p>The number of bits in each index which are used by the slab.</p>
<p>If other data is packed into the <code>usize</code> indices returned by
<ahref="struct.Slab.html#method.insert"title="method sharded_slab::Slab::insert"><code>Slab::insert</code></a>, user code is free to use any bits higher than the
<code>USED_BITS</code>-th bit freely.</p>
<p>This is determined by the <ahref="trait.Config.html"title="trait sharded_slab::Config"><code>Config</code></a> type that configures the slab’s
parameters. By default, all bits are used; this can be changed by
overriding the <ahref="trait.Config.html#RESERVED_BITS"title="trait sharded_slab::Config"><code>Config::RESERVED_BITS</code></a> constant.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.insert"class="method"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#420-430">source</a><h4class="code-header">pub fn <ahref="#method.insert"class="fn">insert</a>(&self, value: T) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.usize.html">usize</a>></h4></section></summary><divclass="docblock"><p>Inserts a value into the slab, returning the integer index at which that
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.vacant_entry"class="method"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#455-467">source</a><h4class="code-header">pub fn <ahref="#method.vacant_entry"class="fn">vacant_entry</a>(&self) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="struct.VacantEntry.html"title="struct sharded_slab::VacantEntry">VacantEntry</a><'_, T, C>></h4></section></summary><divclass="docblock"><p>Return a handle to a vacant entry allowing for further manipulation.</p>
<p>This function is useful when creating values that must contain their
slab index. The returned <ahref="struct.VacantEntry.html"title="struct sharded_slab::VacantEntry"><code>VacantEntry</code></a> reserves a slot in the slab and
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.remove"class="method"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#512-525">source</a><h4class="code-header">pub fn <ahref="#method.remove"class="fn">remove</a>(&self, idx: <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.usize.html">usize</a>) -><aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Remove the value at the given index in the slab, returning <code>true</code> if a
<p>Unlike <ahref="struct.Slab.html#method.take"title="method sharded_slab::Slab::take"><code>take</code></a>, this method does <em>not</em> block the current thread until
the value can be removed. Instead, if another thread is currently
accessing that value, this marks it to be removed by that thread when it
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.take"class="method"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#581-591">source</a><h4class="code-header">pub fn <ahref="#method.take"class="fn">take</a>(&self, idx: <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.usize.html">usize</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html"title="enum core::option::Option">Option</a><T></h4></section></summary><divclass="docblock"><p>Removes the value associated with the given key from the slab, returning
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.get"class="method"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#608-623">source</a><h4class="code-header">pub fn <ahref="#method.get"class="fn">get</a>(&self, key: <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.usize.html">usize</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="struct.Entry.html"title="struct sharded_slab::Entry">Entry</a><'_, T, C>></h4></section></summary><divclass="docblock"><p>Return a reference to the value associated with the given key.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.get_owned"class="method"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#706-721">source</a><h4class="code-header">pub fn <ahref="#method.get_owned"class="fn">get_owned</a>(self: <aclass="struct"href="https://doc.rust-lang.org/1.77.2/alloc/sync/struct.Arc.html"title="struct alloc::sync::Arc">Arc</a><Self>, key: <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.usize.html">usize</a>) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="struct"href="struct.OwnedEntry.html"title="struct sharded_slab::OwnedEntry">OwnedEntry</a><T, C>></h4></section></summary><divclass="docblock"><p>Return an owned reference to the value at the given index.</p>
<p>Unlike <ahref="struct.Slab.html#method.get"title="method sharded_slab::Slab::get"><code>get</code></a>, which borrows the slab, this method <em>clones</em> the <ahref="https://doc.rust-lang.org/1.77.2/alloc/sync/struct.Arc.html"title="struct alloc::sync::Arc"><code>Arc</code></a>
around the slab. This means that the returned <ahref="struct.OwnedEntry.html"title="struct sharded_slab::OwnedEntry"><code>OwnedEntry</code></a> can be held
for an arbitrary lifetime. However, this method requires that the slab
<p>Unlike <ahref="struct.Entry.html"title="struct sharded_slab::Entry"><code>Entry</code></a>, an <code>OwnedEntry</code> may be stored in a struct which must live
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.contains"class="method"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#736-738">source</a><h4class="code-header">pub fn <ahref="#method.contains"class="fn">contains</a>(&self, key: <aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.usize.html">usize</a>) -><aclass="primitive"href="https://doc.rust-lang.org/1.77.2/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Returns <code>true</code> if the slab contains a value for the given key.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.unique_iter"class="method"><aclass="src rightside"href="../src/sharded_slab/lib.rs.html#745-762">source</a><h4class="code-header">pub fn <ahref="#method.unique_iter"class="fn">unique_iter</a>(&mut self) -><aclass="struct"href="struct.UniqueIter.html"title="struct sharded_slab::UniqueIter">UniqueIter</a><'_, T, C><ahref="#"class="tooltip"data-notable-ty="UniqueIter<'_, T, C>">ⓘ</a></h4></section></summary><divclass="docblock"><p>Returns an iterator over all the items in the slab.</p>
<p>Because this iterator exclusively borrows the slab (i.e. it holds an
<code>&mut Slab<T></code>), elements will not be added or removed while the
<code><ahref="https://doc.rust-lang.org/1.77.2/core/convert/trait.From.html"title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-TryFrom%3CU%3E-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.77.2/src/core/convert/mod.rs.html#804-806">source</a><ahref="#impl-TryFrom%3CU%3E-for-T"class="anchor">§</a><h3class="code-header">impl<T, U><aclass="trait"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><U> for T<divclass="where">where
U: <aclass="trait"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.Into.html"title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Error-1"class="associatedtype trait-impl"><ahref="#associatedtype.Error-1"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html#associatedtype.Error"class="associatedtype">Error</a> = <aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/convert/enum.Infallible.html"title="enum core::convert::Infallible">Infallible</a></h4></section></summary><divclass='docblock'>The type returned in the event of a conversion error.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_from"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.77.2/src/core/convert/mod.rs.html#811">source</a><ahref="#method.try_from"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html#tymethod.try_from"class="fn">try_from</a>(value: U) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/result/enum.Result.html"title="enum core::result::Result">Result</a><T, <T as <aclass="trait"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><U>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html#associatedtype.Error"title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><divclass='docblock'>Performs the conversion.</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-TryInto%3CU%3E-for-T"class="impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.77.2/src/core/convert/mod.rs.html#789-791">source</a><ahref="#impl-TryInto%3CU%3E-for-T"class="anchor">§</a><h3class="code-header">impl<T, U><aclass="trait"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryInto.html"title="trait core::convert::TryInto">TryInto</a><U> for T<divclass="where">where
U: <aclass="trait"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Error"class="associatedtype trait-impl"><ahref="#associatedtype.Error"class="anchor">§</a><h4class="code-header">type <ahref="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryInto.html#associatedtype.Error"class="associatedtype">Error</a> = <U as <aclass="trait"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html#associatedtype.Error"title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><divclass='docblock'>The type returned in the event of a conversion error.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_into"class="method trait-impl"><aclass="src rightside"href="https://doc.rust-lang.org/1.77.2/src/core/convert/mod.rs.html#796">source</a><ahref="#method.try_into"class="anchor">§</a><h4class="code-header">fn <ahref="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryInto.html#tymethod.try_into"class="fn">try_into</a>(self) -><aclass="enum"href="https://doc.rust-lang.org/1.77.2/core/result/enum.Result.html"title="enum core::result::Result">Result</a><U, <U as <aclass="trait"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html"title="trait core::convert::TryFrom">TryFrom</a><T>>::<aclass="associatedtype"href="https://doc.rust-lang.org/1.77.2/core/convert/trait.TryFrom.html#associatedtype.Error"title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><divclass='docblock'>Performs the conversion.</div></details></div></details></div><scripttype="text/json"id="notable-traits-data">{"UniqueIter<'_, T, C>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.UniqueIter.html\" title=\"struct sharded_slab::UniqueIter\">UniqueIter</a><'a, T, C></code></h3><pre><code><div class=\"where\">impl<'a, T, C: <a class=\"trait\" href=\"trait.Config.html\" title=\"trait sharded_slab::Config\">Config</a>> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.77.2/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"struct.UniqueIter.html\" title=\"struct sharded_slab::UniqueIter\">UniqueIter</a><'a, T, C></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.77.2/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.77.2/std/primitive.reference.html\">&'a T</a>;</div>"}</script></section></div></main></body></html>