Files
google-apis-rs/tinyvec/index.html
2021-04-02 00:20:57 +08:00

71 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="API documentation for the Rust `tinyvec` crate."><meta name="keywords" content="rust, rustlang, rust-lang, tinyvec"><title>tinyvec - 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="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><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">&#9776;</div><a href='../tinyvec/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate tinyvec</p><div class="block version"><p>Version 1.1.1</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all tinyvec'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="#enums">Enums</a></li><li><a href="#traits">Traits</a></li></ul></div><p class="location"></p><div id="sidebar-vars" data-name="tinyvec" data-ty="mod" data-relpath="../"></div></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" class="help-button">?</button>
<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="in-band">Crate <a class="mod" href="">tinyvec</a></span><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">&#x2212;</span>]</a></span><a class="srclink" href="../src/tinyvec/lib.rs.html#1-111" title="goto source code">[src]</a></span></h1><div class="docblock"><p><code>tinyvec</code> provides 100% safe vec-like data structures.</p>
<h2 id="provided-types" class="section-header"><a href="#provided-types">Provided Types</a></h2>
<p>With no features enabled, this crate provides the <a href="../tinyvec/struct.ArrayVec.html" title="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="../tinyvec/struct.SliceVec.html" title="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="../tinyvec/enum.TinyVec.html" title="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/nightly/core/default/trait.Default.html" title="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>
<h2 id="other-features" class="section-header"><a href="#other-features">Other Features</a></h2>
<ul>
<li><code>grab_spare_slice</code> lets you get access to the &quot;inactive&quot; 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
<a href="../tinyvec/enum.TinyVec.html" title="TinyVec"><code>TinyVec</code></a> and <a href="../tinyvec/struct.ArrayVec.html" title="ArrayVec"><code>ArrayVec</code></a> types, provided the inner item also has an
implementation.</li>
</ul>
<h2 id="api" class="section-header"><a href="#api">API</a></h2>
<p>The general goal of the crate is that, as much as possible, the vecs here
should be a &quot;drop in&quot; 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>
<h2 id="stability" class="section-header"><a href="#stability">Stability</a></h2>
<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><h2 id="macros" class="section-header"><a href="#macros">Macros</a></h2>
<table><tr class="module-item"><td><a class="macro" href="macro.array_vec.html" title="tinyvec::array_vec macro">array_vec</a></td><td class="docblock-short"><p>Helper to make an <code>ArrayVec</code>.</p>
</td></tr><tr class="module-item"><td><a class="macro" href="macro.tiny_vec.html" title="tinyvec::tiny_vec macro">tiny_vec</a></td><td class="docblock-short"><p>Helper to make a <code>TinyVec</code>.</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.ArrayVec.html" title="tinyvec::ArrayVec struct">ArrayVec</a></td><td class="docblock-short"><p>An array-backed, vector-like data structure.</p>
</td></tr><tr class="module-item"><td><a class="struct" href="struct.ArrayVecDrain.html" title="tinyvec::ArrayVecDrain struct">ArrayVecDrain</a></td><td class="docblock-short"><p>Draining iterator for <a href="../tinyvec/struct.ArrayVec.html" title="ArrayVec"><code>ArrayVec</code></a></p>
</td></tr><tr class="module-item"><td><a class="struct" href="struct.ArrayVecIterator.html" title="tinyvec::ArrayVecIterator struct">ArrayVecIterator</a></td><td class="docblock-short"><p>Iterator for consuming an <code>ArrayVec</code> and returning owned elements.</p>
</td></tr><tr class="module-item"><td><a class="struct" href="struct.ArrayVecSplice.html" title="tinyvec::ArrayVecSplice struct">ArrayVecSplice</a></td><td class="docblock-short"><p>Splicing iterator for <code>ArrayVec</code>
See <a href="../tinyvec/struct.ArrayVec.html#method.splice"><code>ArrayVec::splice</code></a></p>
</td></tr><tr class="module-item"><td><a class="struct" href="struct.SliceVec.html" title="tinyvec::SliceVec struct">SliceVec</a></td><td class="docblock-short"><p>A slice-backed vector-like data structure.</p>
</td></tr><tr class="module-item"><td><a class="struct" href="struct.SliceVecDrain.html" title="tinyvec::SliceVecDrain struct">SliceVecDrain</a></td><td class="docblock-short"><p>Draining iterator for <a href="../tinyvec/struct.SliceVec.html" title="SliceVec"><code>SliceVec</code></a></p>
</td></tr><tr class="module-item"><td><a class="struct" href="struct.TinyVecSplice.html" title="tinyvec::TinyVecSplice struct">TinyVecSplice</a></td><td class="docblock-short"><p>Splicing iterator for <code>TinyVec</code>
See <a href="../tinyvec/enum.TinyVec.html#method.splice"><code>TinyVec::splice</code></a></p>
</td></tr></table><h2 id="enums" class="section-header"><a href="#enums">Enums</a></h2>
<table><tr class="module-item"><td><a class="enum" href="enum.TinyVec.html" title="tinyvec::TinyVec enum">TinyVec</a></td><td class="docblock-short"><p>A vector that starts inline, but can automatically move to the heap.</p>
</td></tr><tr class="module-item"><td><a class="enum" href="enum.TinyVecDrain.html" title="tinyvec::TinyVecDrain enum">TinyVecDrain</a></td><td class="docblock-short"><p>Draining iterator for <code>TinyVecDrain</code></p>
</td></tr><tr class="module-item"><td><a class="enum" href="enum.TinyVecIterator.html" title="tinyvec::TinyVecIterator enum">TinyVecIterator</a></td><td class="docblock-short"><p>Iterator for consuming an <code>TinyVec</code> and returning owned elements.</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="tinyvec::Array trait">Array</a></td><td class="docblock-short"><p>A trait for types that are an array.</p>
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="tinyvec"></div>
<script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>