rtic/dev/api/futures_util/future/trait.TryFutureExt.html

284 lines
74 KiB
HTML
Raw Normal View History

<!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="Adapters specific to `Result`-returning futures"><title>TryFutureExt in futures_util::future - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.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-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-b0742ba02757f159.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="futures_util" data-themes="" data-resource-suffix="" data-rustdoc-version="1.83.0 (90b35a623 2024-11-26)" data-channel="1.83.0" data-search-js="search-f0d225181b97f9a4.js" data-settings-js="settings-805db61a62df4bd2.js" ><script src="../../static.files/storage-1d39b6787ed640ff.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-f070b9041d14864c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-0111fcff984fae8f.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc trait"><!--[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="../../futures_util/index.html">futures_<wbr>util</a><span class="version">0.3.31</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">TryFuture<wbr>Ext</a></h2><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.and_then" title="and_then">and_then</a></li><li><a href="#method.err_into" title="err_into">err_into</a></li><li><a href="#method.inspect_err" title="inspect_err">inspect_err</a></li><li><a href="#method.inspect_ok" title="inspect_ok">inspect_ok</a></li><li><a href="#method.into_future" title="into_future">into_future</a></li><li><a href="#method.map_err" title="map_err">map_err</a></li><li><a href="#method.map_ok" title="map_ok">map_ok</a></li><li><a href="#method.map_ok_or_else" title="map_ok_or_else">map_ok_or_else</a></li><li><a href="#method.ok_into" title="ok_into">ok_into</a></li><li><a href="#method.or_else" title="or_else">or_else</a></li><li><a href="#method.try_flatten" title="try_flatten">try_flatten</a></li><li><a href="#method.try_flatten_stream" title="try_flatten_stream">try_flatten_stream</a></li><li><a href="#method.try_poll_unpin" title="try_poll_unpin">try_poll_unpin</a></li><li><a href="#method.unwrap_or_else" title="unwrap_or_else">unwrap_or_else</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In futures_<wbr>util::<wbr>future</a></h2></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"><span class="rustdoc-breadcrumbs"><a href="../index.html">futures_util</a>::<wbr><a href="index.html">future</a></span><h1>Trait <span class="trait">TryFutureExt</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/futures_util/future/try_future/mod.rs.h
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 14 methods</span></summary> // Provided methods
fn <a href="#method.map_ok" class="fn">map_ok</a>&lt;T, F&gt;(self, f: F) -&gt; <a class="struct" href="struct.MapOk.html" title="struct futures_util::future::MapOk">MapOk</a>&lt;Self, F&gt; <a href="#" class="tooltip" data-notable-ty="MapOk&lt;Self, F&gt;"></a>
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>) -&gt; T,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.map_ok_or_else" class="fn">map_ok_or_else</a>&lt;T, E, F&gt;(self, e: E, f: F) -&gt; <a class="struct" href="struct.MapOkOrElse.html" title="struct futures_util::future::MapOkOrElse">MapOkOrElse</a>&lt;Self, F, E&gt; <a href="#" class="tooltip" data-notable-ty="MapOkOrElse&lt;Self, F, E&gt;"></a>
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>) -&gt; T,
E: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>) -&gt; T,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.map_err" class="fn">map_err</a>&lt;E, F&gt;(self, f: F) -&gt; <a class="struct" href="struct.MapErr.html" title="struct futures_util::future::MapErr">MapErr</a>&lt;Self, F&gt; <a href="#" class="tooltip" data-notable-ty="MapErr&lt;Self, F&gt;"></a>
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>) -&gt; E,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.err_into" class="fn">err_into</a>&lt;E&gt;(self) -&gt; <a class="struct" href="struct.ErrInto.html" title="struct futures_util::future::ErrInto">ErrInto</a>&lt;Self, E&gt; <a href="#" class="tooltip" data-notable-ty="ErrInto&lt;Self, E&gt;"></a>
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;E&gt;</span> { ... }
<span class="item-spacer"></span> fn <a href="#method.ok_into" class="fn">ok_into</a>&lt;U&gt;(self) -&gt; <a class="struct" href="struct.OkInto.html" title="struct futures_util::future::OkInto">OkInto</a>&lt;Self, U&gt; <a href="#" class="tooltip" data-notable-ty="OkInto&lt;Self, U&gt;"></a>
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt;</span> { ... }
<span class="item-spacer"></span> fn <a href="#method.and_then" class="fn">and_then</a>&lt;Fut, F&gt;(self, f: F) -&gt; <a class="struct" href="struct.AndThen.html" title="struct futures_util::future::AndThen">AndThen</a>&lt;Self, Fut, F&gt; <a href="#" class="tooltip" data-notable-ty="AndThen&lt;Self, Fut, F&gt;"></a>
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>) -&gt; Fut,
Fut: <a class="trait" href="trait.TryFuture.html" title="trait futures_util::future::TryFuture">TryFuture</a>&lt;Error = Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>&gt;,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.or_else" class="fn">or_else</a>&lt;Fut, F&gt;(self, f: F) -&gt; <a class="struct" href="struct.OrElse.html" title="struct futures_util::future::OrElse">OrElse</a>&lt;Self, Fut, F&gt; <a href="#" class="tooltip" data-notable-ty="OrElse&lt;Self, Fut, F&gt;"></a>
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>) -&gt; Fut,
Fut: <a class="trait" href="trait.TryFuture.html" title="trait futures_util::future::TryFuture">TryFuture</a>&lt;Ok = Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>&gt;,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.inspect_ok" class="fn">inspect_ok</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="struct.InspectOk.html" title="struct futures_util::future::InspectOk">InspectOk</a>&lt;Self, F&gt; <a href="#" class="tooltip" data-notable-ty="InspectOk&lt;Self, F&gt;"></a>
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>),
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.inspect_err" class="fn">inspect_err</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="struct.InspectErr.html" title="struct futures_util::future::InspectErr">InspectErr</a>&lt;Self, F&gt; <a href="#" class="tooltip" data-notable-ty="InspectErr&lt;Self, F&gt;"></a>
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>),
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.try_flatten" class="fn">try_flatten</a>(self) -&gt; <a class="struct" href="struct.TryFlatten.html" title="struct futures_util::future::TryFlatten">TryFlatten</a>&lt;Self, Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>&gt; <a href="#" class="tooltip" data-notable-ty="TryFlatten&lt;Self, Self::Ok&gt;"></a>
<span class="where">where Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>: <a class="trait" href="trait.TryFuture.html" title="trait futures_util::future::TryFuture">TryFuture</a>&lt;Error = Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>&gt;,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.try_flatten_stream" class="fn">try_flatten_stream</a>(self) -&gt; <a class="struct" href="struct.TryFlattenStream.html" title="struct futures_util::future::TryFlattenStream">TryFlattenStream</a>&lt;Self&gt;
<span class="where">where Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>: <a class="trait" href="../stream/trait.TryStream.html" title="trait futures_util::stream::TryStream">TryStream</a>&lt;Error = Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>&gt;,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.unwrap_or_else" class="fn">unwrap_or_else</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="struct.UnwrapOrElse.html" title="struct futures_util::future::UnwrapOrElse">UnwrapOrElse</a>&lt;Self, F&gt; <a href="#" class="tooltip" data-notable-ty="UnwrapOrElse&lt;Self, F&gt;"></a>
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>) -&gt; Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.into_future" class="fn">into_future</a>(self) -&gt; <a class="struct" href="struct.IntoFuture.html" title="struct futures_util::future::IntoFuture">IntoFuture</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="IntoFuture&lt;Self&gt;"></a>
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.try_poll_unpin" class="fn">try_poll_unpin</a>(
&amp;mut self,
cx: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.83.0/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a>&lt;'_&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>&gt;&gt;
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a></span> { ... }
</details>}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Adapters specific to <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a>-returning futures</p>
</div></details><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.map_ok" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#217-223">source</a><h4 class="code-header">fn <a href="#method.map_ok" class="fn">map_ok</a>&lt;T, F&gt;(self, f: F) -&gt; <a class="struct" href="struct.MapOk.html" title="struct futures_util::future::MapOk">MapOk</a>&lt;Self, F&gt; <a href="#" class="tooltip" data-notable-ty="MapOk&lt;Self, F&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>) -&gt; T,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Maps this futures success value to a different value.</p>
<p>This method can be used to change the <a href="trait.TryFuture.html#associatedtype.Ok" title="associated type futures_util::future::TryFuture::Ok"><code>Ok</code></a> type of the
future into a different type. It is similar to the <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#method.map" title="method core::result::Result::map"><code>Result::map</code></a>
method. You can use this method to chain along a computation once the
future has been resolved.</p>
<p>The provided closure <code>f</code> will only be called if this future is resolved
to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a>. If it resolves to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Err" title="variant core::result::Result::Err"><code>Err</code></a>, panics, or is dropped, then
the provided closure will never be invoked.</p>
<p>Note that this method consumes the future it is called on and returns a
wrapped version of it.</p>
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Ok</span>::&lt;i32, i32&gt;(<span class="number">1</span>) };
<span class="kw">let </span>future = future.map_ok(|x| x + <span class="number">3</span>);
<span class="macro">assert_eq!</span>(future.<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="number">4</span>));</code></pre></div>
<p>Calling <a href="trait.TryFutureExt.html#method.map_ok" title="method futures_util::future::TryFutureExt::map_ok"><code>map_ok</code></a> on an errored future has no
effect:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Err</span>::&lt;i32, i32&gt;(<span class="number">1</span>) };
<span class="kw">let </span>future = future.map_ok(|x| x + <span class="number">3</span>);
<span class="macro">assert_eq!</span>(future.<span class="kw">await</span>, <span class="prelude-val">Err</span>(<span class="number">1</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.map_ok_or_else" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#257-264">source</a><h4 class="code-header">fn <a href="#method.map_ok_or_else" class="fn">map_ok_or_else</a>&lt;T, E, F&gt;(self, e: E, f: F) -&gt; <a class="struct" href="struct.MapOkOrElse.html" title="struct futures_util::future::MapOkOrElse">MapOkOrElse</a>&lt;Self, F, E&gt; <a href="#" class="tooltip" data-notable-ty="MapOkOrElse&lt;Self, F, E&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>) -&gt; T,
E: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>) -&gt; T,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Maps this futures success value to a different value, and permits for error handling resulting in the same type.</p>
<p>This method can be used to coalesce your <a href="trait.TryFuture.html#associatedtype.Ok" title="associated type futures_util::future::TryFuture::Ok"><code>Ok</code></a> type and <a href="trait.TryFuture.html#associatedtype.Error" title="associated type futures_util::future::TryFuture::Error"><code>Error</code></a> into another type,
where that type is the same for both outcomes.</p>
<p>The provided closure <code>f</code> will only be called if this future is resolved
to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a>. If it resolves to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Err" title="variant core::result::Result::Err"><code>Err</code></a>, panics, or is dropped, then
the provided closure will never be invoked.</p>
<p>The provided closure <code>e</code> will only be called if this future is resolved
to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Err" title="variant core::result::Result::Err"><code>Err</code></a>. If it resolves to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a>, panics, or is dropped, then
the provided closure will never be invoked.</p>
<p>Note that this method consumes the future it is called on and returns a
wrapped version of it.</p>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Ok</span>::&lt;i32, i32&gt;(<span class="number">5</span>) };
<span class="kw">let </span>future = future.map_ok_or_else(|x| x * <span class="number">2</span>, |x| x + <span class="number">3</span>);
<span class="macro">assert_eq!</span>(future.<span class="kw">await</span>, <span class="number">8</span>);
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Err</span>::&lt;i32, i32&gt;(<span class="number">5</span>) };
<span class="kw">let </span>future = future.map_ok_or_else(|x| x * <span class="number">2</span>, |x| x + <span class="number">3</span>);
<span class="macro">assert_eq!</span>(future.<span class="kw">await</span>, <span class="number">10</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.map_err" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#308-314">source</a><h4 class="code-header">fn <a href="#method.map_err" class="fn">map_err</a>&lt;E, F&gt;(self, f: F) -&gt; <a class="struct" href="struct.MapErr.html" title="struct futures_util::future::MapErr">MapErr</a>&lt;Self, F&gt; <a href="#" class="tooltip" data-notable-ty="MapErr&lt;Self, F&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>) -&gt; E,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Maps this futures error value to a different value.</p>
<p>This method can be used to change the <a href="trait.TryFuture.html#associatedtype.Error" title="associated type futures_util::future::TryFuture::Error"><code>Error</code></a> type
of the future into a different type. It is similar to the
<a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#method.map_err" title="method core::result::Result::map_err"><code>Result::map_err</code></a> method. You can use this method for example to
ensure that futures have the same <a href="trait.TryFuture.html#associatedtype.Error" title="associated type futures_util::future::TryFuture::Error"><code>Error</code></a> type when
using <a href="crate::select"><code>select!</code></a> or <a href="crate::join"><code>join!</code></a>.</p>
<p>The provided closure <code>f</code> will only be called if this future is resolved
to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Err" title="variant core::result::Result::Err"><code>Err</code></a>. If it resolves to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a>, panics, or is dropped, then
the provided closure will never be invoked.</p>
<p>Note that this method consumes the future it is called on and returns a
wrapped version of it.</p>
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Err</span>::&lt;i32, i32&gt;(<span class="number">1</span>) };
<span class="kw">let </span>future = future.map_err(|x| x + <span class="number">3</span>);
<span class="macro">assert_eq!</span>(future.<span class="kw">await</span>, <span class="prelude-val">Err</span>(<span class="number">4</span>));</code></pre></div>
<p>Calling <a href="trait.TryFutureExt.html#method.map_err" title="method futures_util::future::TryFutureExt::map_err"><code>map_err</code></a> on a successful future has
no effect:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Ok</span>::&lt;i32, i32&gt;(<span class="number">1</span>) };
<span class="kw">let </span>future = future.map_err(|x| x + <span class="number">3</span>);
<span class="macro">assert_eq!</span>(future.<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="number">1</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.err_into" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#341-347">source</a><h4 class="code-header">fn <a href="#method.err_into" class="fn">err_into</a>&lt;E&gt;(self) -&gt; <a class="struct" href="struct.ErrInto.html" title="struct futures_util::future::ErrInto">ErrInto</a>&lt;Self, E&gt; <a href="#" class="tooltip" data-notable-ty="ErrInto&lt;Self, E&gt;"></a><div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;E&gt;,</div></h4></section></summary><div class="docblock"><p>Maps this futures <a href="trait.TryFuture.html#associatedtype.Error" title="associated type futures_util::future::TryFuture::Error"><code>Error</code></a> to a new error type
using the <a href="std::convert::Into"><code>Into</code></a> trait.</p>
<p>This method does for futures what the <code>?</code>-operator does for
<a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a>: It lets the compiler infer the type of the resulting
error. Just as <a href="trait.TryFutureExt.html#method.map_err" title="method futures_util::future::TryFutureExt::map_err"><code>map_err</code></a>, this is useful for
example to ensure that futures have the same <a href="trait.TryFuture.html#associatedtype.Error" title="associated type futures_util::future::TryFuture::Error"><code>Error</code></a>
type when using <a href="crate::select"><code>select!</code></a> or <a href="crate::join"><code>join!</code></a>.</p>
<p>Note that this method consumes the future it is called on and returns a
wrapped version of it.</p>
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future_err_u8 = <span class="kw">async </span>{ <span class="prelude-val">Err</span>::&lt;(), u8&gt;(<span class="number">1</span>) };
<span class="kw">let </span>future_err_i32 = future_err_u8.err_into::&lt;i32&gt;();</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.ok_into" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#351-357">source</a><h4 class="code-header">fn <a href="#method.ok_into" class="fn">ok_into</a>&lt;U&gt;(self) -&gt; <a class="struct" href="struct.OkInto.html" title="struct futures_util::future::OkInto">OkInto</a>&lt;Self, U&gt; <a href="#" class="tooltip" data-notable-ty="OkInto&lt;Self, U&gt;"></a><div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt;,</div></h4></section></summary><div class="docblock"><p>Maps this futures <a href="trait.TryFuture.html#associatedtype.Ok" title="associated type futures_util::future::TryFuture::Ok"><code>Ok</code></a> to a new type
using the <a href="std::convert::Into"><code>Into</code></a> trait.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.and_then" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#395-402">source</a><h4 class="code-header">fn <a href="#method.and_then" class="fn">and_then</a>&lt;Fut, F&gt;(self, f: F) -&gt; <a class="struct" href="struct.AndThen.html" title="struct futures_util::future::AndThen">AndThen</a>&lt;Self, Fut, F&gt; <a href="#" class="tooltip" data-notable-ty="AndThen&lt;Self, Fut, F&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>) -&gt; Fut,
Fut: <a class="trait" href="trait.TryFuture.html" title="trait futures_util::future::TryFuture">TryFuture</a>&lt;Error = Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>&gt;,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Executes another future after this one resolves successfully. The
success value is passed to a closure to create this subsequent future.</p>
<p>The provided closure <code>f</code> will only be called if this future is resolved
to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a>. If this future resolves to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Err" title="variant core::result::Result::Err"><code>Err</code></a>, panics, or is
dropped, then the provided closure will never be invoked. The
<a href="trait.TryFuture.html#associatedtype.Error" title="associated type futures_util::future::TryFuture::Error"><code>Error</code></a> type of this future and the future
returned by <code>f</code> have to match.</p>
<p>Note that this method consumes the future it is called on and returns a
wrapped version of it.</p>
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Ok</span>::&lt;i32, i32&gt;(<span class="number">1</span>) };
<span class="kw">let </span>future = future.and_then(|x| <span class="kw">async move </span>{ <span class="prelude-val">Ok</span>::&lt;i32, i32&gt;(x + <span class="number">3</span>) });
<span class="macro">assert_eq!</span>(future.<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="number">4</span>));</code></pre></div>
<p>Calling <a href="trait.TryFutureExt.html#method.and_then" title="method futures_util::future::TryFutureExt::and_then"><code>and_then</code></a> on an errored future has no
effect:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Err</span>::&lt;i32, i32&gt;(<span class="number">1</span>) };
<span class="kw">let </span>future = future.and_then(|x| <span class="kw">async move </span>{ <span class="prelude-val">Err</span>::&lt;i32, i32&gt;(x + <span class="number">3</span>) });
<span class="macro">assert_eq!</span>(future.<span class="kw">await</span>, <span class="prelude-val">Err</span>(<span class="number">1</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.or_else" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#440-447">source</a><h4 class="code-header">fn <a href="#method.or_else" class="fn">or_else</a>&lt;Fut, F&gt;(self, f: F) -&gt; <a class="struct" href="struct.OrElse.html" title="struct futures_util::future::OrElse">OrElse</a>&lt;Self, Fut, F&gt; <a href="#" class="tooltip" data-notable-ty="OrElse&lt;Self, Fut, F&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>) -&gt; Fut,
Fut: <a class="trait" href="trait.TryFuture.html" title="trait futures_util::future::TryFuture">TryFuture</a>&lt;Ok = Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>&gt;,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Executes another future if this one resolves to an error. The
error value is passed to a closure to create this subsequent future.</p>
<p>The provided closure <code>f</code> will only be called if this future is resolved
to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Err" title="variant core::result::Result::Err"><code>Err</code></a>. If this future resolves to an <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a>, panics, or is
dropped, then the provided closure will never be invoked. The
<a href="trait.TryFuture.html#associatedtype.Ok" title="associated type futures_util::future::TryFuture::Ok"><code>Ok</code></a> type of this future and the future returned by <code>f</code>
have to match.</p>
<p>Note that this method consumes the future it is called on and returns a
wrapped version of it.</p>
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Err</span>::&lt;i32, i32&gt;(<span class="number">1</span>) };
<span class="kw">let </span>future = future.or_else(|x| <span class="kw">async move </span>{ <span class="prelude-val">Err</span>::&lt;i32, i32&gt;(x + <span class="number">3</span>) });
<span class="macro">assert_eq!</span>(future.<span class="kw">await</span>, <span class="prelude-val">Err</span>(<span class="number">4</span>));</code></pre></div>
<p>Calling <a href="trait.TryFutureExt.html#method.or_else" title="method futures_util::future::TryFutureExt::or_else"><code>or_else</code></a> on a successful future has
no effect:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Ok</span>::&lt;i32, i32&gt;(<span class="number">1</span>) };
<span class="kw">let </span>future = future.or_else(|x| <span class="kw">async move </span>{ <span class="prelude-val">Ok</span>::&lt;i32, i32&gt;(x + <span class="number">3</span>) });
<span class="macro">assert_eq!</span>(future.<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="number">1</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.inspect_ok" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#467-473">source</a><h4 class="code-header">fn <a href="#method.inspect_ok" class="fn">inspect_ok</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="struct.InspectOk.html" title="struct futures_util::future::InspectOk">InspectOk</a>&lt;Self, F&gt; <a href="#" class="tooltip" data-notable-ty="InspectOk&lt;Self, F&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>),
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Do something with the success value of a future before passing it on.</p>
<p>When using futures, youll often chain several of them together. While
working on such code, you might want to check out whats happening at
various parts in the pipeline, without consuming the intermediate
value. To do that, insert a call to <code>inspect_ok</code>.</p>
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Ok</span>::&lt;<span class="kw">_</span>, ()&gt;(<span class="number">1</span>) };
<span class="kw">let </span>new_future = future.inspect_ok(|<span class="kw-2">&amp;</span>x| <span class="macro">println!</span>(<span class="string">"about to resolve: {}"</span>, x));
<span class="macro">assert_eq!</span>(new_future.<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="number">1</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.inspect_err" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#493-499">source</a><h4 class="code-header">fn <a href="#method.inspect_err" class="fn">inspect_err</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="struct.InspectErr.html" title="struct futures_util::future::InspectErr">InspectErr</a>&lt;Self, F&gt; <a href="#" class="tooltip" data-notable-ty="InspectErr&lt;Self, F&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>),
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Do something with the error value of a future before passing it on.</p>
<p>When using futures, youll often chain several of them together. While
working on such code, you might want to check out whats happening at
various parts in the pipeline, without consuming the intermediate
value. To do that, insert a call to <code>inspect_err</code>.</p>
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Err</span>::&lt;(), <span class="kw">_</span>&gt;(<span class="number">1</span>) };
<span class="kw">let </span>new_future = future.inspect_err(|<span class="kw-2">&amp;</span>x| <span class="macro">println!</span>(<span class="string">"about to error: {}"</span>, x));
<span class="macro">assert_eq!</span>(new_future.<span class="kw">await</span>, <span class="prelude-val">Err</span>(<span class="number">1</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_flatten" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#505-511">source</a><h4 class="code-header">fn <a href="#method.try_flatten" class="fn">try_flatten</a>(self) -&gt; <a class="struct" href="struct.TryFlatten.html" title="struct futures_util::future::TryFlatten">TryFlatten</a>&lt;Self, Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>&gt; <a href="#" class="tooltip" data-notable-ty="TryFlatten&lt;Self, Self::Ok&gt;"></a><div class="where">where
Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>: <a class="trait" href="trait.TryFuture.html" title="trait futures_util::future::TryFuture">TryFuture</a>&lt;Error = Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>&gt;,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Flatten the execution of this future when the successful result of this
future is another future.</p>
<p>This is equivalent to <code>future.and_then(|x| x)</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_flatten_stream" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#538-546">source</a><h4 class="code-header">fn <a href="#method.try_flatten_stream" class="fn">try_flatten_stream</a>(self) -&gt; <a class="struct" href="struct.TryFlattenStream.html" title="struct futures_util::future::TryFlattenStream">TryFlattenStream</a>&lt;Self&gt;<div class="where">where
Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>: <a class="trait" href="../stream/trait.TryStream.html" title="trait futures_util::stream::TryStream">TryStream</a>&lt;Error = Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>&gt;,
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Flatten the execution of this future when the successful result of this
future is a stream.</p>
<p>This can be useful when stream initialization is deferred, and it is
convenient to work with that stream as if stream was available at the
call site.</p>
<p>Note that this function consumes this future and returns a wrapped
version of it.</p>
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">use </span>futures::stream::{<span class="self">self</span>, TryStreamExt};
<span class="kw">let </span>stream_items = <span class="macro">vec!</span>[<span class="number">17</span>, <span class="number">18</span>, <span class="number">19</span>].into_iter().map(<span class="prelude-val">Ok</span>);
<span class="kw">let </span>future_of_a_stream = <span class="kw">async </span>{ <span class="prelude-val">Ok</span>::&lt;<span class="kw">_</span>, ()&gt;(stream::iter(stream_items)) };
<span class="kw">let </span>stream = future_of_a_stream.try_flatten_stream();
<span class="kw">let </span>list = stream.try_collect::&lt;Vec&lt;<span class="kw">_</span>&gt;&gt;().<span class="kw">await</span>;
<span class="macro">assert_eq!</span>(list, <span class="prelude-val">Ok</span>(<span class="macro">vec!</span>[<span class="number">17</span>, <span class="number">18</span>, <span class="number">19</span>]));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.unwrap_or_else" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#570-576">source</a><h4 class="code-header">fn <a href="#method.unwrap_or_else" class="fn">unwrap_or_else</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="struct.UnwrapOrElse.html" title="struct futures_util::future::UnwrapOrElse">UnwrapOrElse</a>&lt;Self, F&gt; <a href="#" class="tooltip" data-notable-ty="UnwrapOrElse&lt;Self, F&gt;"></a><div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
F: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>) -&gt; Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>,</div></h4></section></summary><div class="docblock"><p>Unwraps this futures output, producing a future with this futures
<a href="trait.TryFuture.html#associatedtype.Ok" title="associated type futures_util::future::TryFuture::Ok"><code>Ok</code></a> type as its
<a href="std::future::Future::Output"><code>Output</code></a> type.</p>
<p>If this future is resolved successfully, the returned future will
contain the original futures success value as output. Otherwise, the
closure <code>f</code> is called with the error value to produce an alternate
success value.</p>
<p>This method is similar to the <a href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html#method.unwrap_or_else" title="method core::result::Result::unwrap_or_else"><code>Result::unwrap_or_else</code></a> method.</p>
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::TryFutureExt;
<span class="kw">let </span>future = <span class="kw">async </span>{ <span class="prelude-val">Err</span>::&lt;(), <span class="kw-2">&amp;</span>str&gt;(<span class="string">"Boom!"</span>) };
<span class="kw">let </span>future = future.unwrap_or_else(|<span class="kw">_</span>| ());
<span class="macro">assert_eq!</span>(future.<span class="kw">await</span>, ());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_future" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#610-615">source</a><h4 class="code-header">fn <a href="#method.into_future" class="fn">into_future</a>(self) -&gt; <a class="struct" href="struct.IntoFuture.html" title="struct futures_util::future::IntoFuture">IntoFuture</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="IntoFuture&lt;Self&gt;"></a><div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Wraps a <a href="trait.TryFuture.html" title="trait futures_util::future::TryFuture"><code>TryFuture</code></a> into a type that implements
<a href="std::future::Future"><code>Future</code></a>.</p>
<p><a href="trait.TryFuture.html" title="trait futures_util::future::TryFuture"><code>TryFuture</code></a>s currently do not implement the
<a href="std::future::Future"><code>Future</code></a> trait due to limitations of the
compiler.</p>
<h5 id="examples-10"><a class="doc-anchor" href="#examples-10">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>futures::future::{Future, TryFuture, TryFutureExt};
<span class="kw">fn </span>make_try_future() -&gt; <span class="kw">impl </span>TryFuture&lt;<span class="prelude-val">Ok </span>= T, Error = E&gt; { <span class="comment">// ... }
</span><span class="kw">fn </span>take_future(future: <span class="kw">impl </span>Future&lt;Output = <span class="prelude-ty">Result</span>&lt;T, E&gt;&gt;) { <span class="comment">/* ... */ </span>}
take_future(make_try_future().into_future());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_poll_unpin" class="method"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#619-624">source</a><h4 class="code-header">fn <a href="#method.try_poll_unpin" class="fn">try_poll_unpin</a>(
&amp;mut self,
cx: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.83.0/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a>&lt;'_&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Ok" title="type futures_util::future::TryFuture::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.TryFuture.html#associatedtype.Error" title="type futures_util::future::TryFuture::Error">Error</a>&gt;&gt;<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h4></section></summary><div class="docblock"><p>A convenience method for calling <a href="trait.TryFuture.html#tymethod.try_poll" title="method futures_util::future::TryFuture::try_poll"><code>TryFuture::try_poll</code></a> on <a href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin"><code>Unpin</code></a>
future types.</p>
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-TryFutureExt-for-Fut" class="impl"><a class="src rightside" href="../../src/futures_util/future/try_future/mod.rs.html#134">source</a><a href="#impl-TryFutureExt-for-Fut" class="anchor">§</a><h3 class="code-header">impl&lt;Fut: ?<a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.TryFuture.html" title="trait futures_util::future::TryFuture">TryFuture</a>&gt; <a class="trait" href="trait.TryFutureExt.html" title="trait futures_util::future::TryFutureExt">TryFutureExt</a> for Fut</h3></section></div><script src="../../trait.impl/futures_util/future/try_future/trait.TryFutureExt.js" async></script><script type="text/json" id="notable-traits-data">{"AndThen<Self, Fut, F>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.AndThen.html\" title=\"struct futures_util::future::AndThen\">AndThen</a>&lt;Fut1, Fut2, F&gt;</code></h3><pre><code><div class=\"where\">impl&lt;Fut1, Fut2, F&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.AndThen.html\" title=\"struct futures_util::future::AndThen\">AndThen</a>&lt;Fut1, Fut2, F&gt;<div class=\"where\">where\n <a class=\"struct\" href=\"struct.TryFlatten.html\" title=\"struct futures_util::future::TryFlatten\">TryFlatten</a>&lt;<a class=\"struct\" href=\"struct.MapOk.html\" title=\"struct futures_util::future::MapOk\">MapOk</a>&lt;Fut1, F&gt;, Fut2&gt;: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = &lt;<a class=\"struct\" href=\"struct.TryFlatten.html\" title=\"struct futures_util::future::TryFlatten\">TryFlatten</a>&lt;<a class=\"struct\" href=\"struct.MapOk.html\" title=\"struct futures_util::future::MapOk\">MapOk</a>&lt;Fut1, F&gt;, Fut2&gt; as <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>&gt;::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>;</div>","ErrInto<Self, E>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.ErrInto.html\" title=\"struct futures_util::future::ErrInto\">ErrInto</a>&lt;Fut, E&gt;</code></h3><pre><code><div class=\"where\">impl&lt;Fut, E&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.ErrInto.html\" title=\"struct futures_util::future::ErrInto\">ErrInto</a>&lt;Fut, E&gt;<div class=\"where\">where\n <a class=\"struct\" href=\"struct.MapErr.html\" title=\"struct futures_util::future::MapErr\">MapErr</a>&lt;Fut, IntoFn&lt;E&gt;&gt;: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = &lt;<a class=\"struct\" href=\"struct.MapErr.html\" title=\"struct futures_util::future::MapErr\">MapErr</a>&lt;Fut, IntoFn&lt;E&gt;&gt; as <a class=\"trait\" href=\"https://doc.rust-lang.org/1.83.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>&gt;::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.83.0/core/