Files
GopherGate/target/doc/generic_array/index.html
2026-02-26 12:00:21 -05:00

40 lines
7.7 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="This crate implements a structure that can be used as a generic array type. Core Rust array types `[T; N]` cant be used generically with respect to `N`, so for example this:"><title>generic_array - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="generic_array" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.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]--><rustdoc-topbar><h2><a href="#">Crate generic_array</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../generic_array/index.html">generic_<wbr>array</a><span class="version">0.14.7</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="#reexports">Crate Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>generic_<wbr>array</span>&nbsp;<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/generic_array/lib.rs.html#1-690">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>This crate implements a structure that can be used as a generic array type.
Core Rust array types <code>[T; N]</code> cant be used generically with
respect to <code>N</code>, so for example this:</p>
<div class="example-wrap"><pre class=""><code>struct Foo&lt;T, N&gt; {
data: [T; N]
}</code></pre></div>
<p>wont work.</p>
<p><strong>generic-array</strong> exports a <code>GenericArray&lt;T,N&gt;</code> type, which lets
the above be implemented as:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>generic_array::{ArrayLength, GenericArray};
<span class="kw">struct </span>Foo&lt;T, N: ArrayLength&lt;T&gt;&gt; {
data: GenericArray&lt;T,N&gt;
}</code></pre></div>
<p>The <code>ArrayLength&lt;T&gt;</code> trait is implemented by default for
<a href="../typenum/uint/index.html">unsigned integer types</a> from
<a href="../typenum/index.html">typenum</a>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>generic_array::typenum::U5;
<span class="kw">struct </span>Foo&lt;N: ArrayLength&lt;i32&gt;&gt; {
data: GenericArray&lt;i32, N&gt;
}
<span class="kw">let </span>foo = Foo::&lt;U5&gt;{data: GenericArray::default()};</code></pre></div>
<p>For example, <code>GenericArray&lt;T, U5&gt;</code> would work almost like <code>[T; 5]</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>generic_array::typenum::U5;
<span class="kw">struct </span>Foo&lt;T, N: ArrayLength&lt;T&gt;&gt; {
data: GenericArray&lt;T, N&gt;
}
<span class="kw">let </span>foo = Foo::&lt;i32, U5&gt;{data: GenericArray::default()};</code></pre></div>
<p>For ease of use, an <code>arr!</code> macro is provided - example below:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>array = <span class="macro">arr!</span>[u32; <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="macro">assert_eq!</span>(array[<span class="number">2</span>], <span class="number">3</span>);</code></pre></div></div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><dl class="item-table reexports"><dt><code>pub extern crate <a class="mod" href="../typenum/index.html" title="mod typenum">typenum</a>;</dl><h2 id="reexports-1" class="section-header">Re-exports<a href="#reexports-1" class="anchor">§</a></h2><dl class="item-table reexports"><dt id="reexport.GenericArrayIter"><code>pub use self::iter::<a class="struct" href="iter/struct.GenericArrayIter.html" title="struct generic_array::iter::GenericArrayIter">GenericArrayIter</a>;</code></dt></dl><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="arr/index.html" title="mod generic_array::arr">arr</a></dt><dd>Implementation for <code>arr!</code> macro.</dd><dt><a class="mod" href="functional/index.html" title="mod generic_array::functional">functional</a></dt><dd>Functional programming with generic sequences</dd><dt><a class="mod" href="iter/index.html" title="mod generic_array::iter">iter</a></dt><dd><code>GenericArray</code> iterator implementation.</dd><dt><a class="mod" href="sequence/index.html" title="mod generic_array::sequence">sequence</a></dt><dd>Useful traits for manipulating sequences of data stored in <code>GenericArray</code>s</dd></dl><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><dl class="item-table"><dt><a class="macro" href="macro.arr.html" title="macro generic_array::arr">arr</a></dt><dd>Macro allowing for easy generation of Generic Arrays.
Example: <code>let test = arr![u32; 1, 2, 3];</code></dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.GenericArray.html" title="struct generic_array::GenericArray">Generic<wbr>Array</a></dt><dd>Struct representing a generic array - <code>GenericArray&lt;T, N&gt;</code> works like [T; N]</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.ArrayLength.html" title="trait generic_array::ArrayLength">Array<wbr>Length</a></dt><dd>Trait making <code>GenericArray</code> work, marking types to be used as length of an array</dd></dl></section></div></main></body></html>