Files
google-apis-rs/futures/prelude/future/fn.try_join_all.html
2021-04-02 00:20:57 +08:00

35 lines
10 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 `try_join_all` fn in crate `futures`."><meta name="keywords" content="rust, rustlang, rust-lang, try_join_all"><title>futures::prelude::future::try_join_all - 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 fn"><!--[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='../../../futures/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class="location"><a href="../../index.html">futures</a>::<wbr><a href="../index.html">prelude</a>::<wbr><a href="index.html">future</a></p><div id="sidebar-vars" data-name="try_join_all" data-ty="fn" data-relpath=""></div><script defer src="sidebar-items.js"></script></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">Function <a href="../../index.html">futures</a>::<wbr><a href="../index.html">prelude</a>::<wbr><a href="index.html">future</a>::<wbr><a class="fn" href="">try_join_all</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/futures_util/future/try_join_all.rs.html#90-93" title="goto source code">[src]</a></span></h1><pre class="rust fn">pub fn try_join_all&lt;I&gt;(i: I) -&gt; <a class="struct" href="../../../futures/future/struct.TryJoinAll.html" title="struct futures::future::TryJoinAll">TryJoinAll</a>&lt;&lt;I as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::collect::IntoIterator::Item">Item</a>&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="struct" href="../../../futures/future/struct.TryJoinAll.html" title="struct futures::future::TryJoinAll">TryJoinAll</a>&lt;F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;F&gt; <a class="trait" href="../../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a> for <a class="struct" href="../../../futures/future/struct.TryJoinAll.html" title="struct futures::future::TryJoinAll">TryJoinAll</a>&lt;F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="../../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;&lt;F as <a class="trait" href="../../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a>&gt;::<a class="type" href="../../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/alloc/struct.Global.html" title="struct alloc::alloc::Global">Global</a>&gt;, &lt;F as <a class="trait" href="../../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a>&gt;::<a class="type" href="../../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>&gt;;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;I as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::collect::IntoIterator::Item">Item</a>: <a class="trait" href="../../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a>,&nbsp;</span></pre><div class="docblock"><p>Creates a future which represents either a collection of the results of the
futures given or an error.</p>
<p>The returned future will drive execution for all of its underlying futures,
collecting the results into a destination <code>Vec&lt;T&gt;</code> in the same order as they
were provided.</p>
<p>If any future returns an error then all other futures will be canceled and
an error will be returned immediately. If all futures complete successfully,
however, then the returned future will succeed with a <code>Vec</code> of all the
successful results.</p>
<p>This function is only available when the <code>std</code> or <code>alloc</code> feature of this
library is activated, and it is activated by default.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">future</span>::{<span class="self">self</span>, <span class="ident">try_join_all</span>};
<span class="kw">let</span> <span class="ident">futures</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[
<span class="ident">future</span>::<span class="ident">ok</span>::<span class="op">&lt;</span><span class="ident">u32</span>, <span class="ident">u32</span><span class="op">&gt;</span>(<span class="number">1</span>),
<span class="ident">future</span>::<span class="ident">ok</span>::<span class="op">&lt;</span><span class="ident">u32</span>, <span class="ident">u32</span><span class="op">&gt;</span>(<span class="number">2</span>),
<span class="ident">future</span>::<span class="ident">ok</span>::<span class="op">&lt;</span><span class="ident">u32</span>, <span class="ident">u32</span><span class="op">&gt;</span>(<span class="number">3</span>),
];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">try_join_all</span>(<span class="ident">futures</span>).<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]));
<span class="kw">let</span> <span class="ident">futures</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[
<span class="ident">future</span>::<span class="ident">ok</span>::<span class="op">&lt;</span><span class="ident">u32</span>, <span class="ident">u32</span><span class="op">&gt;</span>(<span class="number">1</span>),
<span class="ident">future</span>::<span class="ident">err</span>::<span class="op">&lt;</span><span class="ident">u32</span>, <span class="ident">u32</span><span class="op">&gt;</span>(<span class="number">2</span>),
<span class="ident">future</span>::<span class="ident">ok</span>::<span class="op">&lt;</span><span class="ident">u32</span>, <span class="ident">u32</span><span class="op">&gt;</span>(<span class="number">3</span>),
];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">try_join_all</span>(<span class="ident">futures</span>).<span class="kw">await</span>, <span class="prelude-val">Err</span>(<span class="number">2</span>));</pre></div>
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="futures"></div>
<script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>