49 lines
11 KiB
HTML
49 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="`tinyvec` provides 100% safe vec-like data structures."><title>tinyvec - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tinyvec" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.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="../tinyvec/index.html">tinyvec</a><span class="version">1.8.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 id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#provided-types" title="Provided Types">Provided Types</a></li><li><a href="#other-features" title="Other Features">Other Features</a></li><li><a href="#api" title="API">API</a></li><li><a href="#stability" title="Stability">Stability</a></li></ul><h3><a href="#macros">Crate Items</a></h3><ul class="block"><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>tinyvec</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tinyvec/lib.rs.html#1-109">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><code>tinyvec</code> provides 100% safe vec-like data structures.</p>
|
||
<h3 id="provided-types"><a class="doc-anchor" href="#provided-types">§</a>Provided Types</h3>
|
||
<p>With no features enabled, this crate provides the <a href="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 <a href="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 <a href="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 <a href="https://doc.rust-lang.org/1.84.0/core/default/trait.Default.html" title="trait core::default::Default"><code>Default</code></a> trait. This means that this crate isn’t suitable for
|
||
all situations, but a very surprising number of types do support <code>Default</code>.</p>
|
||
<h3 id="other-features"><a class="doc-anchor" href="#other-features">§</a>Other Features</h3>
|
||
<ul>
|
||
<li><code>grab_spare_slice</code> lets you get access to the “inactive” portions of an
|
||
ArrayVec.</li>
|
||
<li><code>serde</code> provides a <code>Serialize</code> and <code>Deserialize</code> implementation for
|
||
<a href="enum.TinyVec.html" title="enum tinyvec::TinyVec"><code>TinyVec</code></a> and <a href="struct.ArrayVec.html" title="struct tinyvec::ArrayVec"><code>ArrayVec</code></a> types, provided the inner item also has an
|
||
implementation.</li>
|
||
</ul>
|
||
<h3 id="api"><a class="doc-anchor" href="#api">§</a>API</h3>
|
||
<p>The general goal of the crate is that, as much as possible, the vecs here
|
||
should be a “drop in” replacement for the standard library <code>Vec</code> type. We
|
||
strive to provide all of the <code>Vec</code> methods with the same names and
|
||
signatures. The exception is that the element type of some methods will have
|
||
a <code>Default</code> bound that’s not part of the normal <code>Vec</code> type.</p>
|
||
<p>The vecs here also have a few additional methods that aren’t on the <code>Vec</code>
|
||
type. In this case, the names tend to be fairly long so that they are
|
||
unlikely to clash with any future methods added to <code>Vec</code>.</p>
|
||
<h3 id="stability"><a class="doc-anchor" href="#stability">§</a>Stability</h3>
|
||
<ul>
|
||
<li>The <code>1.0</code> series of the crate works with Rustc <code>1.34.0</code> or later, though
|
||
you still need to have Rustc <code>1.36.0</code> to use the <code>alloc</code> feature.</li>
|
||
<li>The <code>2.0</code> version of the crate is planned for some time after the
|
||
<code>min_const_generics</code> stuff becomes stable. This would greatly raise the
|
||
minimum rust version and also allow us to totally eliminate the need for
|
||
the <code>Array</code> trait. The actual usage of the crate is not expected to break
|
||
significantly in this transition.</li>
|
||
</ul>
|
||
</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.array_vec.html" title="macro tinyvec::array_vec">array_<wbr>vec</a></div><div class="desc docblock-short">Helper to make an <code>ArrayVec</code>.</div></li><li><div class="item-name"><a class="macro" href="macro.tiny_vec.html" title="macro tinyvec::tiny_vec">tiny_<wbr>vec</a></div><div class="desc docblock-short">Helper to make a <code>TinyVec</code>.</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.ArrayVec.html" title="struct tinyvec::ArrayVec">Array<wbr>Vec</a></div><div class="desc docblock-short">An array-backed, vector-like data structure.</div></li><li><div class="item-name"><a class="struct" href="struct.ArrayVecDrain.html" title="struct tinyvec::ArrayVecDrain">Array<wbr>VecDrain</a></div><div class="desc docblock-short">Draining iterator for <a href="struct.ArrayVec.html" title="struct tinyvec::ArrayVec"><code>ArrayVec</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.ArrayVecIterator.html" title="struct tinyvec::ArrayVecIterator">Array<wbr>VecIterator</a></div><div class="desc docblock-short">Iterator for consuming an <code>ArrayVec</code> and returning owned elements.</div></li><li><div class="item-name"><a class="struct" href="struct.ArrayVecSplice.html" title="struct tinyvec::ArrayVecSplice">Array<wbr>VecSplice</a></div><div class="desc docblock-short">Splicing iterator for <code>ArrayVec</code>
|
||
See <a href="struct.ArrayVec.html#method.splice" title="method tinyvec::ArrayVec::splice"><code>ArrayVec::splice</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.SliceVec.html" title="struct tinyvec::SliceVec">Slice<wbr>Vec</a></div><div class="desc docblock-short">A slice-backed vector-like data structure.</div></li><li><div class="item-name"><a class="struct" href="struct.SliceVecDrain.html" title="struct tinyvec::SliceVecDrain">Slice<wbr>VecDrain</a></div><div class="desc docblock-short">Draining iterator for <a href="struct.SliceVec.html" title="struct tinyvec::SliceVec"><code>SliceVec</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.TinyVecSplice.html" title="struct tinyvec::TinyVecSplice">Tiny<wbr>VecSplice</a></div><div class="desc docblock-short">Splicing iterator for <code>TinyVec</code>
|
||
See <a href="enum.TinyVec.html#method.splice" title="method tinyvec::TinyVec::splice"><code>TinyVec::splice</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.TryFromSliceError.html" title="struct tinyvec::TryFromSliceError">TryFrom<wbr>Slice<wbr>Error</a></div><div class="desc docblock-short">The error type returned when a conversion from a slice to an <a href="struct.ArrayVec.html" title="struct tinyvec::ArrayVec"><code>ArrayVec</code></a>
|
||
fails.</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.TinyVec.html" title="enum tinyvec::TinyVec">TinyVec</a></div><div class="desc docblock-short">A vector that starts inline, but can automatically move to the heap.</div></li><li><div class="item-name"><a class="enum" href="enum.TinyVecDrain.html" title="enum tinyvec::TinyVecDrain">Tiny<wbr>VecDrain</a></div><div class="desc docblock-short">Draining iterator for <code>TinyVecDrain</code></div></li><li><div class="item-name"><a class="enum" href="enum.TinyVecIterator.html" title="enum tinyvec::TinyVecIterator">Tiny<wbr>VecIterator</a></div><div class="desc docblock-short">Iterator for consuming an <code>TinyVec</code> and returning owned elements.</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 tinyvec::Array">Array</a></div><div class="desc docblock-short">A trait for types that are an array.</div></li></ul></section></div></main></body></html> |