mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-10 01:58:23 +00:00
54 lines
11 KiB
HTML
54 lines
11 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="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-5bc39a1768837dd0.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.77.0 (aedd173a2 2024-03-17)" data-channel="1.77.0" data-search-js="search-dd67cee4cfa65049.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-4c98445ec4002617.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-48f368f3872407c8.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-04d5337699b92874.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" title="show sidebar"></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>−</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 class="doc-anchor" href="#no_std-support">§</a><code>no_std</code> support</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 class="doc-anchor" href="#optional-features">§</a>Optional features</h3><h4 id="serde"><a class="doc-anchor" href="#serde">§</a><code>serde</code></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 class="doc-anchor" href="#write">§</a><code>write</code></h4>
|
||
<p>When this feature is enabled, <code>SmallVec<[u8; _]></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 class="doc-anchor" href="#union">§</a><code>union</code></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 = ["union"]</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 class="doc-anchor" href="#const_generics">§</a><code>const_generics</code></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 class="doc-anchor" href="#const_new">§</a><code>const_new</code></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 class="doc-anchor" href="#drain_filter">§</a><code>drain_filter</code></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 class="doc-anchor" href="#drain_keep_rest">§</a><code>drain_keep_rest</code></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 class="doc-anchor" href="#specialization">§</a><code>specialization</code></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 class="doc-anchor" href="#may_dangle">§</a><code>may_dangle</code></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">Macros<a href="#macros" class="anchor">§</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">Structs<a href="#structs" class="anchor">§</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">Enums<a href="#enums" class="anchor">§</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">Traits<a href="#traits" class="anchor">§</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> |