edlang/smallvec/index.html
2024-02-13 06:38:44 +00:00

54 lines
11 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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="Small vectors in various sizes. These store a certain number of elements inline, and fall back to the heap for larger allocations. This can be a useful optimization for improving cache locality and reducing allocator traffic for workloads that fit within the inline buffer."><title>smallvec - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-ac92e1bbe349e143.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="smallvec" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0 (07dca489a 2024-02-04)" data-channel="1.76.0" data-search-js="search-2b6ce74ff89ae146.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-f2adc0d6ca4d09fb.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-305769736d49e732.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-feafe1bb7466e4bd.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../smallvec/index.html">smallvec</a><span class="version">1.13.1</span></h2></div><div class="sidebar-elems"><ul class="block">
<li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#macros">Macros</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li></ul></section></div></nav><div class="sidebar-resizer"></div>
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../smallvec/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">smallvec</a><button id="copy-path" title="Copy item path to clipboard"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../src/smallvec/lib.rs.html#7-2471">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Small vectors in various sizes. These store a certain number of elements inline, and fall back
to the heap for larger allocations. This can be a useful optimization for improving cache
locality and reducing allocator traffic for workloads that fit within the inline buffer.</p>
<h3 id="no_std-support"><a href="#no_std-support"><code>no_std</code> support</a></h3>
<p>By default, <code>smallvec</code> does not depend on <code>std</code>. However, the optional
<code>write</code> feature implements the <code>std::io::Write</code> trait for vectors of <code>u8</code>.
When this feature is enabled, <code>smallvec</code> depends on <code>std</code>.</p>
<h3 id="optional-features"><a href="#optional-features">Optional features</a></h3><h4 id="serde"><a href="#serde"><code>serde</code></a></h4>
<p>When this optional dependency is enabled, <code>SmallVec</code> implements the <code>serde::Serialize</code> and
<code>serde::Deserialize</code> traits.</p>
<h4 id="write"><a href="#write"><code>write</code></a></h4>
<p>When this feature is enabled, <code>SmallVec&lt;[u8; _]&gt;</code> implements the <code>std::io::Write</code> trait.
This feature is not compatible with <code>#![no_std]</code> programs.</p>
<h4 id="union"><a href="#union"><code>union</code></a></h4>
<p><strong>This feature requires Rust 1.49.</strong></p>
<p>When the <code>union</code> feature is enabled <code>smallvec</code> will track its state (inline or spilled)
without the use of an enum tag, reducing the size of the <code>smallvec</code> by one machine word.
This means that there is potentially no space overhead compared to <code>Vec</code>.
Note that <code>smallvec</code> can still be larger than <code>Vec</code> if the inline buffer is larger than two
machine words.</p>
<p>To use this feature add <code>features = [&quot;union&quot;]</code> in the <code>smallvec</code> section of Cargo.toml.
Note that this feature requires Rust 1.49.</p>
<p>Tracking issue: <a href="https://github.com/rust-lang/rust/issues/55149">rust-lang/rust#55149</a></p>
<h4 id="const_generics"><a href="#const_generics"><code>const_generics</code></a></h4>
<p><strong>This feature requires Rust 1.51.</strong></p>
<p>When this feature is enabled, <code>SmallVec</code> works with any arrays of any size, not just a fixed
list of sizes.</p>
<h4 id="const_new"><a href="#const_new"><code>const_new</code></a></h4>
<p><strong>This feature requires Rust 1.51.</strong></p>
<p>This feature exposes the functions [<code>SmallVec::new_const</code>], [<code>SmallVec::from_const</code>], and [<code>smallvec_inline</code>] which enables the <code>SmallVec</code> to be initialized from a const context.
For details, see the
<a href="https://doc.rust-lang.org/reference/const_eval.html#const-functions">Rust Reference</a>.</p>
<h4 id="drain_filter"><a href="#drain_filter"><code>drain_filter</code></a></h4>
<p><strong>This feature is unstable.</strong> It may change to match the unstable <code>drain_filter</code> method in libstd.</p>
<p>Enables the <code>drain_filter</code> method, which produces an iterator that calls a user-provided
closure to determine which elements of the vector to remove and yield from the iterator.</p>
<h4 id="drain_keep_rest"><a href="#drain_keep_rest"><code>drain_keep_rest</code></a></h4>
<p><strong>This feature is unstable.</strong> It may change to match the unstable <code>drain_keep_rest</code> method in libstd.</p>
<p>Enables the <code>DrainFilter::keep_rest</code> method.</p>
<h4 id="specialization"><a href="#specialization"><code>specialization</code></a></h4>
<p><strong>This feature is unstable and requires a nightly build of the Rust toolchain.</strong></p>
<p>When this feature is enabled, <code>SmallVec::from(slice)</code> has improved performance for slices
of <code>Copy</code> types. (Without this feature, you can use <code>SmallVec::from_slice</code> to get optimal
performance for <code>Copy</code> types.)</p>
<p>Tracking issue: <a href="https://github.com/rust-lang/rust/issues/31844">rust-lang/rust#31844</a></p>
<h4 id="may_dangle"><a href="#may_dangle"><code>may_dangle</code></a></h4>
<p><strong>This feature is unstable and requires a nightly build of the Rust toolchain.</strong></p>
<p>This feature makes the Rust compiler less strict about use of vectors that contain borrowed
references. For details, see the
<a href="https://doc.rust-lang.org/1.42.0/nomicon/dropck.html#an-escape-hatch">Rustonomicon</a>.</p>
<p>Tracking issue: <a href="https://github.com/rust-lang/rust/issues/34761">rust-lang/rust#34761</a></p>
</div></details><h2 id="macros" class="section-header"><a href="#macros">Macros</a></h2><ul class="item-table"><li><div class="item-name"><a class="macro" href="macro.smallvec.html" title="macro smallvec::smallvec">smallvec</a></div><div class="desc docblock-short">Creates a <a href="struct.SmallVec.html" title="struct smallvec::SmallVec"><code>SmallVec</code></a> containing the arguments.</div></li></ul><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Drain.html" title="struct smallvec::Drain">Drain</a></div><div class="desc docblock-short">An iterator that removes the items from a <code>SmallVec</code> and yields them by value.</div></li><li><div class="item-name"><a class="struct" href="struct.IntoIter.html" title="struct smallvec::IntoIter">IntoIter</a></div><div class="desc docblock-short">An iterator that consumes a <code>SmallVec</code> and yields its items by value.</div></li><li><div class="item-name"><a class="struct" href="struct.SmallVec.html" title="struct smallvec::SmallVec">SmallVec</a></div><div class="desc docblock-short">A <code>Vec</code>-like container that can store a small number of elements inline.</div></li></ul><h2 id="enums" class="section-header"><a href="#enums">Enums</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.CollectionAllocErr.html" title="enum smallvec::CollectionAllocErr">CollectionAllocErr</a></div><div class="desc docblock-short">Error type for APIs with fallible heap allocation</div></li></ul><h2 id="traits" class="section-header"><a href="#traits">Traits</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.Array.html" title="trait smallvec::Array">Array</a></div><div class="desc docblock-short">Types that can be used as the backing store for a <a href="struct.SmallVec.html" title="struct smallvec::SmallVec"><code>SmallVec</code></a>.</div></li><li><div class="item-name"><a class="trait" href="trait.ToSmallVec.html" title="trait smallvec::ToSmallVec">ToSmallVec</a></div><div class="desc docblock-short">Convenience trait for constructing a <code>SmallVec</code></div></li></ul></section></div></main></body></html>