Deploying to gh-pages from @ GreptimeTeam/greptimedb@9aebf3a821 🚀

This commit is contained in:
github-merge-queue[bot] committed 2026-11-27 16:59:42 +00:00
commit adb61e7613
29801 files changed
+3488123

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
(function() {
var type_impls = Object.fromEntries([["flow",[["<details class=\"toggle implementors-toggle\" open><summary><section id=\"impl-%5BT;+N%5D\" class=\"impl\"><a class=\"src rightside\" href=\"https://doc.rust-lang.org/1.98.1/src/core/array/mod.rs.html#520\">Source</a><a href=\"#impl-%5BT;+N%5D\" class=\"anchor\">§</a><h3 class=\"code-header\">impl&lt;T, const N: <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.98.1/std/primitive.usize.html\">usize</a>&gt; <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.98.1/std/primitive.array.html\">[T; N]</a></h3></section></summary><div class=\"impl-items\"><details class=\"toggle method-toggle\" open><summary><section id=\"method.map\" class=\"method\"><span class=\"rightside\"><span class=\"since\" title=\"Stable since Rust version 1.55.0, const unstable\">1.55.0 (const: <a href=\"https://github.com/rust-lang/rust/issues/147606\" title=\"Tracking issue for const_array\">unstable</a>)</span> · <a class=\"src\" href=\"https://doc.rust-lang.org/1.98.1/src/core/array/mod.rs.html#592-596\">Source</a></span><h4 class=\"code-header\">pub fn <a href=\"#method.map\" class=\"fn\">map</a>&lt;F, U&gt;(self, f: F) -&gt; <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.98.1/std/primitive.array.html\">[U; N]</a><div class=\"where\">where\n F: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.98.1/core/ops/function/trait.FnMut.html\" title=\"trait core::ops::function::FnMut\">FnMut</a>(T) -&gt; U,</div></h4></section></summary><div class=\"docblock\"><p>Returns an array of the same size as <code>self</code>, with function <code>f</code> applied to each element\nin order.</p>\n<p>If you don’t necessarily need a new fixed-size array, consider using\n<a href=\"https://doc.rust-lang.org/1.98.1/core/iter/traits/iterator/trait.Iterator.html#method.map\" title=\"method core::iter::traits::iterator::Iterator::map\"><code>Iterator::map</code></a> instead.</p>\n<h5 id=\"note-on-performance-and-stack-usage\"><a class=\"doc-anchor\" href=\"#note-on-performance-and-stack-usage\">§</a>Note on performance and stack usage</h5>\n<p>Note that this method is <em>eager</em>. It evaluates <code>f</code> all <code>N</code> times before\nreturning the new array.</p>\n<p>That means that <code>arr.map(f).map(g)</code> is, in general, <em>not</em> equivalent to\n<code>array.map(|x| g(f(x)))</code>, as the former calls <code>f</code> 4 times then <code>g</code> 4 times,\nwhereas the latter interleaves the calls (<code>fgfgfgfg</code>).</p>\n<p>A consequence of this is that it can have fairly-high stack usage, especially\nin debug mode or for long arrays. The backend may be able to optimize it\naway, but especially for complicated mappings it might not be able to.</p>\n<p>If you’re doing a one-step <code>map</code> and really want an array as the result,\nthen absolutely use this method. Its implementation uses a bunch of tricks\nto help the optimizer handle it well. Particularly for simple arrays,\nlike <code>[u8; 3]</code> or <code>[f32; 4]</code>, there’s nothing to be concerned about.</p>\n<p>However, if you don’t actually need an <em>array</em> of the results specifically,\njust to process them, then you likely want <a href=\"https://doc.rust-lang.org/1.98.1/core/iter/traits/iterator/trait.Iterator.html#method.map\" title=\"method core::iter::traits::iterator::Iterator::map\"><code>Iterator::map</code></a> instead.</p>\n<p>For example, rather than doing an array-to-array map of all the elements\nin the array up-front and only iterating after that completes,</p>\n\n<div class=\"example-wrap\"><pre class=\"rust rust-example-rendered\"><code><span class=\"kw\">for </span>x <span class=\"kw\">in </span>my_array.map(f) {\n <span class=\"comment\">// ...\n</span>}</code></pre></div>\n<p>It’s often better to use an iterator along the lines of</p>\n\n<div class=\"example-wrap\"><pre class=\"rust rust-example-rendered\"><code><span class=\"kw\">for </span>x <span class=\"kw\">in </span>my_array.into_iter().map(f) {\n <span class=\"comment\">// ...\n</span>}</code></pre></div>\n<p>as that’s more likely to avoid large temporaries.</p>\n<h5 id=\"examples\"><a class=\"doc-anchor\" href=\"#examples\">§</a>Examples</h5>\n<div class=\"example-wrap\"><pre class=\"rust rust-example-rendered\"><code><span class=\"kw\">let </span>x = [<span class=\"number\">1</span>, <span class=\"number\">2</span>, <span class=\"number\">3</span>];\n<span class=\"kw\">let </span>y = x.map(|v| v + <span class=\"number\">1</span>);\n<span class=\"macro\">assert_eq!</span>(y, [<span class=\"number\">2</span>, <span class=\"number\">3</span>, <span class=\"number\">4</span>]);\n\n<span class=\"kw\">let </span>x = [<span class=\"number\">1</span>, <span class=\"number\">2</span>, <span class=\"number\">3</span>];\n<span class=\"kw\">let </span><span class=\"kw-2\">mut </span>temp = <span class=\"number\">0</span>;\n<span class=\"kw\">let </span>y = x.map(|v| { temp += <span class=\"numLine truncated
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
//{"start":55,"fragment_lengths":[510800,3085027]}