<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="`tinyvec` provides 100% safe vec-like data structures."><title>tinyvec - Rust</title><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><linkrel="stylesheet"href="../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet"href="../static.files/rustdoc-5bc39a1768837dd0.css"><metaname="rustdoc-vars"data-root-path="../"data-static-root-path="../static.files/"data-current-crate="tinyvec"data-themes=""data-resource-suffix=""data-rustdoc-version="1.77.2 (25ef9e3d8 2024-04-09)"data-channel="1.77.2"data-search-js="search-dd67cee4cfa65049.js"data-settings-js="settings-4313503d2e1961c2.js"><scriptsrc="../static.files/storage-4c98445ec4002617.js"></script><scriptdefersrc="../crates.js"></script><scriptdefersrc="../static.files/main-48f368f3872407c8.js"></script><noscript><linkrel="stylesheet"href="../static.files/noscript-04d5337699b92874.css"></noscript><linkrel="alternate icon"type="image/png"href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><linkrel="alternate icon"type="image/png"href="../static.files/favicon-32x32-422f7d1d52889060.png"><linkrel="icon"type="image/svg+xml"href="../static.files/favicon-2c020d218678b618.svg"></head><bodyclass="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle"title="show sidebar"></button></nav><navclass="sidebar"><divclass="sidebar-crate"><h2><ahref="../tinyvec/index.html">tinyvec</a><spanclass="version">1.6.0</span></h2></div><divclass="sidebar-elems"><ulclass="block">
<main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><divid="sidebar-button"tabindex="-1"><ahref="../tinyvec/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>Crate <aclass="mod"href="#">tinyvec</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/tinyvec/lib.rs.html#1-107">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p><code>tinyvec</code> provides 100% safe vec-like data structures.</p>
<p>With no features enabled, this crate provides the <ahref="struct.ArrayVec.html"title="struct tinyvec::ArrayVec"><code>ArrayVec</code></a> type, which
is an array-backed storage. You can push values into the array and pop them
out of the array and so on. If the array is made to overflow it will panic.</p>
<p>Similarly, there is also a <ahref="struct.SliceVec.html"title="struct tinyvec::SliceVec"><code>SliceVec</code></a> type available, which is a vec-like
that’s backed by a slice you provide. You can add and remove elements, but
if you overflow the slice it will panic.</p>
<p>With the <code>alloc</code> feature enabled, the crate also has a <ahref="enum.TinyVec.html"title="enum tinyvec::TinyVec"><code>TinyVec</code></a> type.
This is an enum type which is either an <code>Inline(ArrayVec)</code> or a <code>Heap(Vec)</code>.
If a <code>TinyVec</code> is <code>Inline</code> and would overflow it automatically transitions
itself into being <code>Heap</code> mode instead of a panic.</p>
<p>All of this is done with no <code>unsafe</code> code within the crate. Technically the
<code>Vec</code> type from the standard library uses <code>unsafe</code> internally, but <em>this
crate</em> introduces no new <code>unsafe</code> code into your project.</p>
<p>The limitation is that the element type of a vec from this crate must
support the <ahref="https://doc.rust-lang.org/1.77.2/core/default/trait.Default.html"title="trait core::default::Default"><code>Default</code></a> trait. This means that this crate isn’t suitable for
<li><code>grab_spare_slice</code> lets you get access to the “inactive” portions of an
ArrayVec.</li>
<li><code>rustc_1_40</code> makes the crate assume a minimum rust version of <code>1.40.0</code>,
which allows some better internal optimizations.</li>
<li><code>serde</code> provides a <code>Serialize</code> and <code>Deserialize</code> implementation for
<ahref="enum.TinyVec.html"title="enum tinyvec::TinyVec"><code>TinyVec</code></a> and <ahref="struct.ArrayVec.html"title="struct tinyvec::ArrayVec"><code>ArrayVec</code></a> types, provided the inner item also has an
</div></details><h2id="macros"class="section-header">Macros<ahref="#macros"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="macro"href="macro.array_vec.html"title="macro tinyvec::array_vec">array_vec</a></div><divclass="desc docblock-short">Helper to make an <code>ArrayVec</code>.</div></li><li><divclass="item-name"><aclass="macro"href="macro.tiny_vec.html"title="macro tinyvec::tiny_vec">tiny_vec</a></div><divclass="desc docblock-short">Helper to make a <code>TinyVec</code>.</div></li></ul><h2id="structs"class="section-header">Structs<ahref="#structs"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="struct"href="struct.ArrayVec.html"title="struct tinyvec::ArrayVec">ArrayVec</a></div><divclass="desc docblock-short">An array-backed, vector-like data structure.</div></li><li><divclass="item-name"><aclass="struct"href="struct.ArrayVecDrain.html"title="struct tinyvec::ArrayVecDrain">ArrayVecDrain</a></div><divclass="desc docblock-short">Draining iterator for <ahref="struct.ArrayVec.html"title="struct tinyvec::ArrayVec"><code>ArrayVec</code></a></div></li><li><divclass="item-name"><aclass="struct"href="struct.ArrayVecIterator.html"title="struct tinyvec::ArrayVecIterator">ArrayVecIterator</a></div><divclass="desc docblock-short">Iterator for consuming an <code>ArrayVec</code> and returning owned elements.</div></li><li><divclass="item-name"><aclass="struct"href="struct.ArrayVecSplice.html"title="struct tinyvec::ArrayVecSplice">ArrayVecSplice</a></div><divclass="desc docblock-short">Splicing iterator for <code>ArrayVec</code>
See <ahref="struct.ArrayVec.html#method.splice"title="method tinyvec::ArrayVec::splice"><code>ArrayVec::splice</code></a></div></li><li><divclass="item-name"><aclass="struct"href="struct.SliceVec.html"title="struct tinyvec::SliceVec">SliceVec</a></div><divclass="desc docblock-short">A slice-backed vector-like data structure.</div></li><li><divclass="item-name"><aclass="struct"href="struct.SliceVecDrain.html"title="struct tinyvec::SliceVecDrain">SliceVecDrain</a></div><divclass="desc docblock-short">Draining iterator for <ahref="struct.SliceVec.html"title="struct tinyvec::SliceVec"><code>SliceVec</code></a></div></li><li><divclass="item-name"><aclass="struct"href="struct.TinyVecSplice.html"title="struct tinyvec::TinyVecSplice">TinyVecSplice</a></div><divclass="desc docblock-short">Splicing iterator for <code>TinyVec</code>
See <ahref="enum.TinyVec.html#method.splice"title="method tinyvec::TinyVec::splice"><code>TinyVec::splice</code></a></div></li><li><divclass="item-name"><aclass="struct"href="struct.TryFromSliceError.html"title="struct tinyvec::TryFromSliceError">TryFromSliceError</a></div><divclass="desc docblock-short">The error type returned when a conversion from a slice to an <ahref="struct.ArrayVec.html"title="struct tinyvec::ArrayVec"><code>ArrayVec</code></a>
fails.</div></li></ul><h2id="enums"class="section-header">Enums<ahref="#enums"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="enum"href="enum.TinyVec.html"title="enum tinyvec::TinyVec">TinyVec</a></div><divclass="desc docblock-short">A vector that starts inline, but can automatically move to the heap.</div></li><li><divclass="item-name"><aclass="enum"href="enum.TinyVecDrain.html"title="enum tinyvec::TinyVecDrain">TinyVecDrain</a></div><divclass="desc docblock-short">Draining iterator for <code>TinyVecDrain</code></div></li><li><divclass="item-name"><aclass="enum"href="enum.TinyVecIterator.html"title="enum tinyvec::TinyVecIterator">TinyVecIterator</a></div><divclass="desc docblock-short">Iterator for consuming an <code>TinyVec</code> and returning owned elements.</div></li></ul><h2id="traits"class="section-header">Traits<ahref="#traits"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="trait"href="trait.Array.html"title="trait tinyvec::Array">Array</a></div><divclass="desc docblock-short">A trait for types that are an array.</div></li></ul></section></div></main></body></html>