|
|
|
|
<!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 `smallvec` crate."><meta name="keywords" content="rust, rustlang, rust-lang, smallvec"><title>smallvec - 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="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[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><a href='../smallvec/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Crate smallvec</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all smallvec's items</p></a><div class="block items"><ul><li><a href="#macros">Macros</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'smallvec', ty: 'mod', relpath: '../'};</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"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><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/smallvec/lib.rs.html#7-2360' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>smallvec</a></span></h1><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>
|
|
|
|
|
<h2 id="no_std-support" class="section-header"><a href="#no_std-support">no_std support</a></h2>
|
|
|
|
|
<p>By default, <code>smallvec</code> depends on <code>libstd</code>. However, it can be configured to use the unstable
|
|
|
|
|
<code>liballoc</code> API instead, for use on platforms that have <code>liballoc</code> but not <code>libstd</code>. This
|
|
|
|
|
configuration is currently unstable and is not guaranteed to work on all versions of Rust.</p>
|
|
|
|
|
<p>To depend on <code>smallvec</code> without <code>libstd</code>, use <code>default-features = false</code> in the <code>smallvec</code>
|
|
|
|
|
section of Cargo.toml to disable its <code>"std"</code> feature.</p>
|
|
|
|
|
<h2 id="union-feature" class="section-header"><a href="#union-feature"><code>union</code> feature</a></h2>
|
|
|
|
|
<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 = ["union"]</code> in the <code>smallvec</code> section of Cargo.toml.
|
|
|
|
|
Note that this feature requires a nightly compiler (for now).</p>
|
|
|
|
|
</div><h2 id='macros' class='section-header'><a href="#macros">Macros</a></h2>
|
|
|
|
|
<table><tr class='module-item'><td><a class="macro" href="macro.smallvec.html" title='smallvec::smallvec macro'>smallvec</a></td><td class='docblock-short'><p>Creates a [<code>SmallVec</code>] containing the arguments.</p>
|
|
|
|
|
</td></tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
|
|
|
|
|
<table><tr class='module-item'><td><a class="struct" href="struct.Drain.html" title='smallvec::Drain struct'>Drain</a></td><td class='docblock-short'><p>An iterator that removes the items from a <code>SmallVec</code> and yields them by value.</p>
|
|
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.IntoIter.html" title='smallvec::IntoIter struct'>IntoIter</a></td><td class='docblock-short'><p>An iterator that consumes a <code>SmallVec</code> and yields its items by value.</p>
|
|
|
|
|
</td></tr><tr class='module-item'><td><a class="struct" href="struct.SmallVec.html" title='smallvec::SmallVec struct'>SmallVec</a></td><td class='docblock-short'><p>A <code>Vec</code>-like container that can store a small number of elements inline.</p>
|
|
|
|
|
</td></tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
|
|
|
|
|
<table><tr class='module-item'><td><a class="trait" href="trait.Array.html" title='smallvec::Array trait'>Array</a></td><td class='docblock-short'><p>Types that can be used as the backing store for a SmallVec</p>
|
|
|
|
|
</td></tr><tr class='module-item'><td><a class="trait" href="trait.ExtendFromSlice.html" title='smallvec::ExtendFromSlice trait'>ExtendFromSlice</a></td><td class='docblock-short'><p>Trait to be implemented by a collection that can be extended from a slice</p>
|
|
|
|
|
</td></tr><tr class='module-item'><td><a class="trait" href="trait.VecLike.html" title='smallvec::VecLike trait'>VecLike</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>Common operations implemented by both <code>Vec</code> and <code>SmallVec</code>.</p>
|
|
|
|
|
</td></tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
|
|
|
|
|
<table><tr class='module-item'><td><a class="fn" href="fn.unreachable.html" title='smallvec::unreachable fn'>unreachable</a><a title='unsafe function' href='#'><sup>⚠</sup></a></td><td class='docblock-short'><p>Hint to the optimizer that any code path which calls this function is
|
|
|
|
|
statically unreachable and can be removed.</p>
|
|
|
|
|
</td></tr></table></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><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "smallvec";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|