Files
google-apis-rs/futures/future/trait.TryFutureExt.html
2021-04-02 00:20:57 +08:00

273 lines
106 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 `TryFutureExt` trait in crate `futures`."><meta name="keywords" content="rust, rustlang, rust-lang, TryFutureExt"><title>futures::future::TryFutureExt - 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 trait"><!--[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><p class="location">Trait TryFutureExt</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.and_then">and_then</a><a href="#method.err_into">err_into</a><a href="#method.map_err">map_err</a><a href="#method.into_future">into_future</a><a href="#method.try_flatten">try_flatten</a><a href="#method.or_else">or_else</a><a href="#method.flatten_sink">flatten_sink</a><a href="#method.map_ok">map_ok</a><a href="#method.map_ok_or_else">map_ok_or_else</a><a href="#method.ok_into">ok_into</a><a href="#method.inspect_ok">inspect_ok</a><a href="#method.inspect_err">inspect_err</a><a href="#method.try_flatten_stream">try_flatten_stream</a><a href="#method.unwrap_or_else">unwrap_or_else</a><a href="#method.try_poll_unpin">try_poll_unpin</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">futures</a>::<wbr><a href="index.html">future</a></p><div id="sidebar-vars" data-name="TryFutureExt" data-ty="trait" 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">Trait <a href="../index.html">futures</a>::<wbr><a href="index.html">future</a>::<wbr><a class="trait" href="">TryFutureExt</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_future/mod.rs.html#137-619" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait TryFutureExt: <a class="trait" href="../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a> {
pub fn <a href="#method.flatten_sink" class="fnname">flatten_sink</a>&lt;Item&gt;(self) -&gt; <a class="struct" href="../../futures/future/struct.FlattenSink.html" title="struct futures::future::FlattenSink">FlattenSink</a>&lt;Self, Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>: <a class="trait" href="../../futures/sink/trait.Sink.html" title="trait futures::sink::Sink">Sink</a>&lt;Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a> as <a class="trait" href="../../futures/sink/trait.Sink.html" title="trait futures::sink::Sink">Sink</a>&lt;Item&gt;&gt;::<a class="type" href="../../futures/sink/trait.Sink.html#associatedtype.Error" title="type futures::sink::Sink::Error">Error</a> == Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a></span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.map_ok" class="fnname">map_ok</a>&lt;T, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Self, F&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.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, 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.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, MapOkFn&lt;F&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, MapOkFn&lt;F&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>) -&gt; T</span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.map_ok_or_else" class="fnname">map_ok_or_else</a>&lt;T, E, F&gt;(self, e: E, f: F) -&gt; <a class="struct" href="../../futures/future/struct.MapOkOrElse.html" title="struct futures::future::MapOkOrElse">MapOkOrElse</a>&lt;Self, F, E&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.MapOkOrElse.html" title="struct futures::future::MapOkOrElse">MapOkOrElse</a>&lt;Fut, F, G&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, F, G&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.MapOkOrElse.html" title="struct futures::future::MapOkOrElse">MapOkOrElse</a>&lt;Fut, F, G&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, ChainFn&lt;MapOkFn&lt;F&gt;, ChainFn&lt;MapErrFn&lt;G&gt;, MergeResultFn&gt;&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, ChainFn&lt;MapOkFn&lt;F&gt;, ChainFn&lt;MapErrFn&lt;G&gt;, MergeResultFn&gt;&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;E: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>) -&gt; T,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>) -&gt; T</span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.map_err" class="fnname">map_err</a>&lt;E, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Self, F&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.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, 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.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, MapErrFn&lt;F&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, MapErrFn&lt;F&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>) -&gt; E</span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.err_into" class="fnname">err_into</a>&lt;E&gt;(self) -&gt; <a class="struct" href="../../futures/future/struct.ErrInto.html" title="struct futures::future::ErrInto">ErrInto</a>&lt;Self, E&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.ErrInto.html" title="struct futures::future::ErrInto">ErrInto</a>&lt;Fut, E&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, E&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.ErrInto.html" title="struct futures::future::ErrInto">ErrInto</a>&lt;Fut, E&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut, IntoFn&lt;E&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut, IntoFn&lt;E&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;E&gt;</span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.ok_into" class="fnname">ok_into</a>&lt;U&gt;(self) -&gt; <a class="struct" href="../../futures/future/struct.OkInto.html" title="struct futures::future::OkInto">OkInto</a>&lt;Self, U&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.OkInto.html" title="struct futures::future::OkInto">OkInto</a>&lt;Fut, E&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, E&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.OkInto.html" title="struct futures::future::OkInto">OkInto</a>&lt;Fut, E&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut, IntoFn&lt;E&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut, IntoFn&lt;E&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt;</span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.and_then" class="fnname">and_then</a>&lt;Fut, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.AndThen.html" title="struct futures::future::AndThen">AndThen</a>&lt;Self, Fut, F&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.AndThen.html" title="struct futures::future::AndThen">AndThen</a>&lt;Fut1, Fut2, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut1, Fut2, 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.AndThen.html" title="struct futures::future::AndThen">AndThen</a>&lt;Fut1, Fut2, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.TryFlatten.html" title="struct futures::future::TryFlatten">TryFlatten</a>&lt;<a class="struct" href="../../futures/future/struct.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut1, F&gt;, Fut2&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.TryFlatten.html" title="struct futures::future::TryFlatten">TryFlatten</a>&lt;<a class="struct" href="../../futures/future/struct.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut1, F&gt;, Fut2&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>) -&gt; Fut,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fut: <a class="trait" href="../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a>&lt;Error = Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>&gt;</span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.or_else" class="fnname">or_else</a>&lt;Fut, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.OrElse.html" title="struct futures::future::OrElse">OrElse</a>&lt;Self, Fut, F&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.OrElse.html" title="struct futures::future::OrElse">OrElse</a>&lt;Fut1, Fut2, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut1, Fut2, 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.OrElse.html" title="struct futures::future::OrElse">OrElse</a>&lt;Fut1, Fut2, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;TryFlattenErr&lt;<a class="struct" href="../../futures/future/struct.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut1, F&gt;, Fut2&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;TryFlattenErr&lt;<a class="struct" href="../../futures/future/struct.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut1, F&gt;, Fut2&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>) -&gt; Fut,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fut: <a class="trait" href="../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a>&lt;Ok = Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>&gt;</span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.inspect_ok" class="fnname">inspect_ok</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.InspectOk.html" title="struct futures::future::InspectOk">InspectOk</a>&lt;Self, F&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.InspectOk.html" title="struct futures::future::InspectOk">InspectOk</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, 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.InspectOk.html" title="struct futures::future::InspectOk">InspectOk</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Inspect.html" title="struct futures::future::Inspect">Inspect</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, InspectOkFn&lt;F&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Inspect.html" title="struct futures::future::Inspect">Inspect</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, InspectOkFn&lt;F&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>)</span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.inspect_err" class="fnname">inspect_err</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.InspectErr.html" title="struct futures::future::InspectErr">InspectErr</a>&lt;Self, F&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.InspectErr.html" title="struct futures::future::InspectErr">InspectErr</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, 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.InspectErr.html" title="struct futures::future::InspectErr">InspectErr</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Inspect.html" title="struct futures::future::Inspect">Inspect</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, InspectErrFn&lt;F&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Inspect.html" title="struct futures::future::Inspect">Inspect</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, InspectErrFn&lt;F&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>)</span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.try_flatten" class="fnname">try_flatten</a>(self) -&gt; <a class="struct" href="../../futures/future/struct.TryFlatten.html" title="struct futures::future::TryFlatten">TryFlatten</a>&lt;Self, Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</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.TryFlatten.html" title="struct futures::future::TryFlatten">TryFlatten</a>&lt;Fut1, Fut2&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut1, Fut2&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.TryFlatten.html" title="struct futures::future::TryFlatten">TryFlatten</a>&lt;Fut1, Fut2&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;TryFlatten&lt;Fut1, Fut2&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;TryFlatten&lt;Fut1, Fut2&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>: <a class="trait" href="../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a> 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> == Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a></span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.try_flatten_stream" class="fnname">try_flatten_stream</a>(self) -&gt; <a class="struct" href="../../futures/future/struct.TryFlattenStream.html" title="struct futures::future::TryFlattenStream">TryFlattenStream</a>&lt;Self&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>: <a class="trait" href="../../futures/stream/trait.TryStream.html" title="trait futures::stream::TryStream">TryStream</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a> as <a class="trait" href="../../futures/stream/trait.TryStream.html" title="trait futures::stream::TryStream">TryStream</a>&gt;::<a class="type" href="../../futures/stream/trait.TryStream.html#associatedtype.Error" title="type futures::stream::TryStream::Error">Error</a> == Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a></span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.unwrap_or_else" class="fnname">unwrap_or_else</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.UnwrapOrElse.html" title="struct futures::future::UnwrapOrElse">UnwrapOrElse</a>&lt;Self, F&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.UnwrapOrElse.html" title="struct futures::future::UnwrapOrElse">UnwrapOrElse</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, 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.UnwrapOrElse.html" title="struct futures::future::UnwrapOrElse">UnwrapOrElse</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, UnwrapOrElseFn&lt;F&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, UnwrapOrElseFn&lt;F&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>) -&gt; Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a></span>,
{ ... }
<div class="item-spacer"></div> pub fn <a href="#method.into_future" class="fnname">into_future</a>(self) -&gt; <a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Self&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.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut&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.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Fut: <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;&lt;Fut 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>, &lt;Fut 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> { ... }
<div class="item-spacer"></div> pub fn <a href="#method.try_poll_unpin" class="fnname">try_poll_unpin</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cx: &amp;mut <a class="struct" href="../../futures/task/struct.Context.html" title="struct futures::task::Context">Context</a>&lt;'_&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="../../futures/task/enum.Poll.html" title="enum futures::task::Poll">Poll</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>, Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>&gt;&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a></span>,
{ ... }
}</pre></div><div class="docblock"><p>Adapters specific to <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="Result"><code>Result</code></a>-returning futures</p>
</div><h2 id="provided-methods" class="small-section-header">Provided methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><h3 id="method.flatten_sink" class="method"><code>pub fn <a href="#method.flatten_sink" class="fnname">flatten_sink</a>&lt;Item&gt;(self) -&gt; <a class="struct" href="../../futures/future/struct.FlattenSink.html" title="struct futures::future::FlattenSink">FlattenSink</a>&lt;Self, Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>: <a class="trait" href="../../futures/sink/trait.Sink.html" title="trait futures::sink::Sink">Sink</a>&lt;Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a> as <a class="trait" href="../../futures/sink/trait.Sink.html" title="trait futures::sink::Sink">Sink</a>&lt;Item&gt;&gt;::<a class="type" href="../../futures/sink/trait.Sink.html#associatedtype.Error" title="type futures::sink::Sink::Error">Error</a> == Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#171-174" title="goto source code">[src]</a></h3><div class="docblock"><p>Flattens the execution of this future when the successful result of this
future is a <a href="../../futures/sink/trait.Sink.html" title="Sink"><code>Sink</code></a>.</p>
<p>This can be useful when sink initialization is deferred, and it is
convenient to work with that sink as if the sink was available at the
call site.</p>
<p>Note that this function consumes this future and returns a wrapped
version of it.</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="ident">Future</span>, <span class="ident">TryFutureExt</span>};
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">sink</span>::<span class="ident">Sink</span>;
<span class="kw">fn</span> <span class="ident">make_sink_async</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="kw">impl</span> <span class="ident">Future</span><span class="op">&lt;</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span>
<span class="kw">impl</span> <span class="ident">Sink</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">Error</span> <span class="op">=</span> <span class="ident">E</span><span class="op">&gt;</span>,
<span class="ident">E</span>,
<span class="op">&gt;</span><span class="op">&gt;</span> { <span class="comment">// ... }</span>
<span class="kw">fn</span> <span class="ident">take_sink</span>(<span class="ident">sink</span>: <span class="kw">impl</span> <span class="ident">Sink</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">Error</span> <span class="op">=</span> <span class="ident">E</span><span class="op">&gt;</span>) { <span class="comment">/* ... */</span> }
<span class="kw">let</span> <span class="ident">fut</span> <span class="op">=</span> <span class="ident">make_sink_async</span>();
<span class="ident">take_sink</span>(<span class="ident">fut</span>.<span class="ident">flatten_sink</span>())</pre></div>
</div><h3 id="method.map_ok" class="method"><code>pub fn <a href="#method.map_ok" class="fnname">map_ok</a>&lt;T, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Self, F&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.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, 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.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, MapOkFn&lt;F&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, MapOkFn&lt;F&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>) -&gt; T,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#217-220" title="goto source code">[src]</a></h3><div class="docblock"><p>Maps this future's success value to a different value.</p>
<p>This method can be used to change the <a href="../../futures/future/trait.TryFuture.html#associatedtype.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/nightly/core/result/enum.Result.html#method.map" title="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/nightly/core/result/enum.Result.html#variant.Ok" title="Ok"><code>Ok</code></a>. If it resolves to an <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Err" title="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>
<h1 id="examples-1" class="section-header"><a href="#examples-1">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="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Ok</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="number">1</span>) };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">map_ok</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span> <span class="op">+</span> <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="number">4</span>));</pre></div>
<p>Calling <a href="../../futures/future/trait.TryFutureExt.html#method.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">
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">future</span>::<span class="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Err</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="number">1</span>) };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">map_ok</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span> <span class="op">+</span> <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="prelude-val">Err</span>(<span class="number">1</span>));</pre></div>
</div><h3 id="method.map_ok_or_else" class="method"><code>pub fn <a href="#method.map_ok_or_else" class="fnname">map_ok_or_else</a>&lt;T, E, F&gt;(self, e: E, f: F) -&gt; <a class="struct" href="../../futures/future/struct.MapOkOrElse.html" title="struct futures::future::MapOkOrElse">MapOkOrElse</a>&lt;Self, F, E&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.MapOkOrElse.html" title="struct futures::future::MapOkOrElse">MapOkOrElse</a>&lt;Fut, F, G&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, F, G&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.MapOkOrElse.html" title="struct futures::future::MapOkOrElse">MapOkOrElse</a>&lt;Fut, F, G&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, ChainFn&lt;MapOkFn&lt;F&gt;, ChainFn&lt;MapErrFn&lt;G&gt;, MergeResultFn&gt;&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, ChainFn&lt;MapOkFn&lt;F&gt;, ChainFn&lt;MapErrFn&lt;G&gt;, MergeResultFn&gt;&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;E: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>) -&gt; T,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>) -&gt; T,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#257-261" title="goto source code">[src]</a></h3><div class="docblock"><p>Maps this future's 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="../../futures/future/trait.TryFuture.html#associatedtype.Ok"><code>Ok</code></a> type and <a href="../../futures/future/trait.TryFuture.html#associatedtype.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/nightly/core/result/enum.Result.html#variant.Ok" title="Ok"><code>Ok</code></a>. If it resolves to an <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Err" title="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/nightly/core/result/enum.Result.html#variant.Err" title="Err"><code>Err</code></a>. If it resolves to an <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Ok" title="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>
<h1 id="examples-2" class="section-header"><a href="#examples-2">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="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Ok</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="number">5</span>) };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">map_ok_or_else</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span> <span class="op">*</span> <span class="number">2</span>, <span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span> <span class="op">+</span> <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="number">8</span>);
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Err</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="number">5</span>) };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">map_ok_or_else</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span> <span class="op">*</span> <span class="number">2</span>, <span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span> <span class="op">+</span> <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="number">10</span>);</pre></div>
</div><h3 id="method.map_err" class="method"><code>pub fn <a href="#method.map_err" class="fnname">map_err</a>&lt;E, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Self, F&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.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, 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.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, MapErrFn&lt;F&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, MapErrFn&lt;F&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>) -&gt; E,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#305-308" title="goto source code">[src]</a></h3><div class="docblock"><p>Maps this future's error value to a different value.</p>
<p>This method can be used to change the <a href="../../futures/future/trait.TryFuture.html#associatedtype.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/nightly/core/result/enum.Result.html#method.map_err" title="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="../../futures/future/trait.TryFuture.html#associatedtype.Error"><code>Error</code></a> type when
using <a href="../../futures/macro.select.html" title="select!"><code>select!</code></a> or <a href="../../futures/macro.join.html" title="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/nightly/core/result/enum.Result.html#variant.Err" title="Err"><code>Err</code></a>. If it resolves to an <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Ok" title="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>
<h1 id="examples-3" class="section-header"><a href="#examples-3">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="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Err</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="number">1</span>) };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span> <span class="op">+</span> <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="prelude-val">Err</span>(<span class="number">4</span>));</pre></div>
<p>Calling <a href="../../futures/future/trait.TryFutureExt.html#method.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">
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">future</span>::<span class="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Ok</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="number">1</span>) };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">map_err</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span> <span class="op">+</span> <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="number">1</span>));</pre></div>
</div><h3 id="method.err_into" class="method"><code>pub fn <a href="#method.err_into" class="fnname">err_into</a>&lt;E&gt;(self) -&gt; <a class="struct" href="../../futures/future/struct.ErrInto.html" title="struct futures::future::ErrInto">ErrInto</a>&lt;Self, E&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.ErrInto.html" title="struct futures::future::ErrInto">ErrInto</a>&lt;Fut, E&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, E&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.ErrInto.html" title="struct futures::future::ErrInto">ErrInto</a>&lt;Fut, E&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut, IntoFn&lt;E&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut, IntoFn&lt;E&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;E&gt;,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#335-338" title="goto source code">[src]</a></h3><div class="docblock"><p>Maps this future's <a href="../../futures/future/trait.TryFuture.html#associatedtype.Error"><code>Error</code></a> to a new error type
using the <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html"><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/nightly/core/result/enum.Result.html" title="Result"><code>Result</code></a>: It lets the compiler infer the type of the resulting
error. Just as <a href="../../futures/future/trait.TryFutureExt.html#method.map_err"><code>map_err</code></a>, this is useful for
example to ensure that futures have the same <a href="../../futures/future/trait.TryFuture.html#associatedtype.Error"><code>Error</code></a>
type when using <a href="../../futures/macro.select.html" title="select!"><code>select!</code></a> or <a href="../../futures/macro.join.html" title="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>
<h1 id="examples-4" class="section-header"><a href="#examples-4">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="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future_err_u8</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Err</span>::<span class="op">&lt;</span>(), <span class="ident">u8</span><span class="op">&gt;</span>(<span class="number">1</span>) };
<span class="kw">let</span> <span class="ident">future_err_i32</span> <span class="op">=</span> <span class="ident">future_err_u8</span>.<span class="ident">err_into</span>::<span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span>();</pre></div>
</div><h3 id="method.ok_into" class="method"><code>pub fn <a href="#method.ok_into" class="fnname">ok_into</a>&lt;U&gt;(self) -&gt; <a class="struct" href="../../futures/future/struct.OkInto.html" title="struct futures::future::OkInto">OkInto</a>&lt;Self, U&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.OkInto.html" title="struct futures::future::OkInto">OkInto</a>&lt;Fut, E&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, E&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.OkInto.html" title="struct futures::future::OkInto">OkInto</a>&lt;Fut, E&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut, IntoFn&lt;E&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut, IntoFn&lt;E&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt;,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#345-348" title="goto source code">[src]</a></h3><div class="docblock"><p>Maps this future's <a href="../../futures/future/trait.TryFuture.html#associatedtype.Ok"><code>Ok</code></a> to a new type
using the <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html"><code>Into</code></a> trait.</p>
</div><h3 id="method.and_then" class="method"><code>pub fn <a href="#method.and_then" class="fnname">and_then</a>&lt;Fut, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.AndThen.html" title="struct futures::future::AndThen">AndThen</a>&lt;Self, Fut, F&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.AndThen.html" title="struct futures::future::AndThen">AndThen</a>&lt;Fut1, Fut2, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut1, Fut2, 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.AndThen.html" title="struct futures::future::AndThen">AndThen</a>&lt;Fut1, Fut2, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.TryFlatten.html" title="struct futures::future::TryFlatten">TryFlatten</a>&lt;<a class="struct" href="../../futures/future/struct.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut1, F&gt;, Fut2&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.TryFlatten.html" title="struct futures::future::TryFlatten">TryFlatten</a>&lt;<a class="struct" href="../../futures/future/struct.MapOk.html" title="struct futures::future::MapOk">MapOk</a>&lt;Fut1, F&gt;, Fut2&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>) -&gt; Fut,<br>&nbsp;&nbsp;&nbsp;&nbsp;Fut: <a class="trait" href="../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a>&lt;Error = Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>&gt;,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#389-393" title="goto source code">[src]</a></h3><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/nightly/core/result/enum.Result.html#variant.Ok" title="Ok"><code>Ok</code></a>. If this future resolves to an <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Err" title="Err"><code>Err</code></a>, panics, or is
dropped, then the provided closure will never be invoked. The
<a href="../../futures/future/trait.TryFuture.html#associatedtype.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>
<h1 id="examples-5" class="section-header"><a href="#examples-5">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="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Ok</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="number">1</span>) };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">and_then</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> { <span class="prelude-val">Ok</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="ident">x</span> <span class="op">+</span> <span class="number">3</span>) });
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="number">4</span>));</pre></div>
<p>Calling <a href="../../futures/future/trait.TryFutureExt.html#method.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">
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">future</span>::<span class="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Err</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="number">1</span>) };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">and_then</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> { <span class="prelude-val">Err</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="ident">x</span> <span class="op">+</span> <span class="number">3</span>) });
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="prelude-val">Err</span>(<span class="number">1</span>));</pre></div>
</div><h3 id="method.or_else" class="method"><code>pub fn <a href="#method.or_else" class="fnname">or_else</a>&lt;Fut, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.OrElse.html" title="struct futures::future::OrElse">OrElse</a>&lt;Self, Fut, F&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.OrElse.html" title="struct futures::future::OrElse">OrElse</a>&lt;Fut1, Fut2, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut1, Fut2, 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.OrElse.html" title="struct futures::future::OrElse">OrElse</a>&lt;Fut1, Fut2, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;TryFlattenErr&lt;<a class="struct" href="../../futures/future/struct.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut1, F&gt;, Fut2&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;TryFlattenErr&lt;<a class="struct" href="../../futures/future/struct.MapErr.html" title="struct futures::future::MapErr">MapErr</a>&lt;Fut1, F&gt;, Fut2&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>) -&gt; Fut,<br>&nbsp;&nbsp;&nbsp;&nbsp;Fut: <a class="trait" href="../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a>&lt;Ok = Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>&gt;,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#434-438" title="goto source code">[src]</a></h3><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/nightly/core/result/enum.Result.html#variant.Err" title="Err"><code>Err</code></a>. If this future resolves to an <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Ok" title="Ok"><code>Ok</code></a>, panics, or is
dropped, then the provided closure will never be invoked. The
<a href="../../futures/future/trait.TryFuture.html#associatedtype.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>
<h1 id="examples-6" class="section-header"><a href="#examples-6">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="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Err</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="number">1</span>) };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">or_else</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> { <span class="prelude-val">Err</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="ident">x</span> <span class="op">+</span> <span class="number">3</span>) });
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="prelude-val">Err</span>(<span class="number">4</span>));</pre></div>
<p>Calling <a href="../../futures/future/trait.TryFutureExt.html#method.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">
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">future</span>::<span class="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Ok</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="number">1</span>) };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">or_else</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="kw">async</span> <span class="kw">move</span> { <span class="prelude-val">Ok</span>::<span class="op">&lt;</span><span class="ident">i32</span>, <span class="ident">i32</span><span class="op">&gt;</span>(<span class="ident">x</span> <span class="op">+</span> <span class="number">3</span>) });
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="number">1</span>));</pre></div>
</div><h3 id="method.inspect_ok" class="method"><code>pub fn <a href="#method.inspect_ok" class="fnname">inspect_ok</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.InspectOk.html" title="struct futures::future::InspectOk">InspectOk</a>&lt;Self, F&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.InspectOk.html" title="struct futures::future::InspectOk">InspectOk</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, 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.InspectOk.html" title="struct futures::future::InspectOk">InspectOk</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Inspect.html" title="struct futures::future::Inspect">Inspect</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, InspectOkFn&lt;F&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Inspect.html" title="struct futures::future::Inspect">Inspect</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, InspectOkFn&lt;F&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>),&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#461-464" title="goto source code">[src]</a></h3><div class="docblock"><p>Do something with the success value of a future before passing it on.</p>
<p>When using futures, you'll often chain several of them together. While
working on such code, you might want to check out what's happening at
various parts in the pipeline, without consuming the intermediate
value. To do that, insert a call to <code>inspect_ok</code>.</p>
<h1 id="examples-7" class="section-header"><a href="#examples-7">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="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Ok</span>::<span class="op">&lt;</span><span class="kw">_</span>, ()<span class="op">&gt;</span>(<span class="number">1</span>) };
<span class="kw">let</span> <span class="ident">new_future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">inspect_ok</span>(<span class="op">|</span><span class="kw-2">&amp;</span><span class="ident">x</span><span class="op">|</span> <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;about to resolve: {}&quot;</span>, <span class="ident">x</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">new_future</span>.<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="number">1</span>));</pre></div>
</div><h3 id="method.inspect_err" class="method"><code>pub fn <a href="#method.inspect_err" class="fnname">inspect_err</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.InspectErr.html" title="struct futures::future::InspectErr">InspectErr</a>&lt;Self, F&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.InspectErr.html" title="struct futures::future::InspectErr">InspectErr</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, 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.InspectErr.html" title="struct futures::future::InspectErr">InspectErr</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Inspect.html" title="struct futures::future::Inspect">Inspect</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, InspectErrFn&lt;F&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Inspect.html" title="struct futures::future::Inspect">Inspect</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, InspectErrFn&lt;F&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>),&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#487-490" title="goto source code">[src]</a></h3><div class="docblock"><p>Do something with the error value of a future before passing it on.</p>
<p>When using futures, you'll often chain several of them together. While
working on such code, you might want to check out what's happening at
various parts in the pipeline, without consuming the intermediate
value. To do that, insert a call to <code>inspect_err</code>.</p>
<h1 id="examples-8" class="section-header"><a href="#examples-8">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="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Err</span>::<span class="op">&lt;</span>(), <span class="kw">_</span><span class="op">&gt;</span>(<span class="number">1</span>) };
<span class="kw">let</span> <span class="ident">new_future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">inspect_err</span>(<span class="op">|</span><span class="kw-2">&amp;</span><span class="ident">x</span><span class="op">|</span> <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;about to error: {}&quot;</span>, <span class="ident">x</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">new_future</span>.<span class="kw">await</span>, <span class="prelude-val">Err</span>(<span class="number">1</span>));</pre></div>
</div><h3 id="method.try_flatten" class="method"><code>pub fn <a href="#method.try_flatten" class="fnname">try_flatten</a>(self) -&gt; <a class="struct" href="../../futures/future/struct.TryFlatten.html" title="struct futures::future::TryFlatten">TryFlatten</a>&lt;Self, Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</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.TryFlatten.html" title="struct futures::future::TryFlatten">TryFlatten</a>&lt;Fut1, Fut2&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut1, Fut2&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.TryFlatten.html" title="struct futures::future::TryFlatten">TryFlatten</a>&lt;Fut1, Fut2&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;TryFlatten&lt;Fut1, Fut2&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;TryFlatten&lt;Fut1, Fut2&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>: <a class="trait" href="../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a> 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> == Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#499-502" title="goto source code">[src]</a></h3><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><h3 id="method.try_flatten_stream" class="method"><code>pub fn <a href="#method.try_flatten_stream" class="fnname">try_flatten_stream</a>(self) -&gt; <a class="struct" href="../../futures/future/struct.TryFlattenStream.html" title="struct futures::future::TryFlattenStream">TryFlattenStream</a>&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>: <a class="trait" href="../../futures/stream/trait.TryStream.html" title="trait futures::stream::TryStream">TryStream</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a> as <a class="trait" href="../../futures/stream/trait.TryStream.html" title="trait futures::stream::TryStream">TryStream</a>&gt;::<a class="type" href="../../futures/stream/trait.TryStream.html#associatedtype.Error" title="type futures::stream::TryStream::Error">Error</a> == Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#532-535" title="goto source code">[src]</a></h3><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>
<h1 id="examples-9" class="section-header"><a href="#examples-9">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="ident">TryFutureExt</span>;
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">stream</span>::{<span class="self">self</span>, <span class="ident">TryStreamExt</span>};
<span class="kw">let</span> <span class="ident">stream_items</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">17</span>, <span class="number">18</span>, <span class="number">19</span>].<span class="ident">into_iter</span>().<span class="ident">map</span>(<span class="prelude-val">Ok</span>);
<span class="kw">let</span> <span class="ident">future_of_a_stream</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Ok</span>::<span class="op">&lt;</span><span class="kw">_</span>, ()<span class="op">&gt;</span>(<span class="ident">stream</span>::<span class="ident">iter</span>(<span class="ident">stream_items</span>)) };
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">future_of_a_stream</span>.<span class="ident">try_flatten_stream</span>();
<span class="kw">let</span> <span class="ident">list</span> <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">try_collect</span>::<span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span><span class="op">&gt;</span>().<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">list</span>, <span class="prelude-val">Ok</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">17</span>, <span class="number">18</span>, <span class="number">19</span>]));</pre></div>
</div><h3 id="method.unwrap_or_else" class="method"><code>pub fn <a href="#method.unwrap_or_else" class="fnname">unwrap_or_else</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures/future/struct.UnwrapOrElse.html" title="struct futures::future::UnwrapOrElse">UnwrapOrElse</a>&lt;Self, F&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.UnwrapOrElse.html" title="struct futures::future::UnwrapOrElse">UnwrapOrElse</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, 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.UnwrapOrElse.html" title="struct futures::future::UnwrapOrElse">UnwrapOrElse</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, UnwrapOrElseFn&lt;F&gt;&gt;: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="../../futures/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures/future/struct.Map.html" title="struct futures::future::Map">Map</a>&lt;<a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;, UnwrapOrElseFn&lt;F&gt;&gt; as <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a>&gt;::<a class="type" href="../../futures/future/trait.Future.html#associatedtype.Output" title="type futures::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>) -&gt; Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#564-567" title="goto source code">[src]</a></h3><div class="docblock"><p>Unwraps this future's output, producing a future with this future's
<a href="../../futures/future/trait.TryFuture.html#associatedtype.Ok"><code>Ok</code></a> type as its
<a href="../../futures/future/trait.Future.html#associatedtype.Output"><code>Output</code></a> type.</p>
<p>If this future is resolved successfully, the returned future will
contain the original future's 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/nightly/core/result/enum.Result.html#method.unwrap_or_else" title="Result::unwrap_or_else"><code>Result::unwrap_or_else</code></a> method.</p>
<h1 id="examples-10" class="section-header"><a href="#examples-10">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="ident">TryFutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="prelude-val">Err</span>::<span class="op">&lt;</span>(), <span class="kw-2">&amp;</span><span class="ident">str</span><span class="op">&gt;</span>(<span class="string">&quot;Boom!&quot;</span>) };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">unwrap_or_else</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> ());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, ());</pre></div>
</div><h3 id="method.into_future" class="method"><code>pub fn <a href="#method.into_future" class="fnname">into_future</a>(self) -&gt; <a class="struct" href="../../futures/future/struct.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Self&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.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut&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.IntoFuture.html" title="struct futures::future::IntoFuture">IntoFuture</a>&lt;Fut&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Fut: <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;&lt;Fut 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>, &lt;Fut 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></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#604-606" title="goto source code">[src]</a></h3><div class="docblock"><p>Wraps a <a href="../../futures/future/trait.TryFuture.html" title="TryFuture"><code>TryFuture</code></a> into a type that implements
<a href="../../futures/future/trait.Future.html"><code>Future</code></a>.</p>
<p><a href="../../futures/future/trait.TryFuture.html" title="TryFuture"><code>TryFuture</code></a>s currently do not implement the
<a href="../../futures/future/trait.Future.html"><code>Future</code></a> trait due to limitations of the
compiler.</p>
<h1 id="examples-11" class="section-header"><a href="#examples-11">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="ident">Future</span>, <span class="ident">TryFuture</span>, <span class="ident">TryFutureExt</span>};
<span class="kw">fn</span> <span class="ident">make_try_future</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="kw">impl</span> <span class="ident">TryFuture</span><span class="op">&lt;</span><span class="prelude-val">Ok</span> <span class="op">=</span> <span class="ident">T</span>, <span class="ident">Error</span> <span class="op">=</span> <span class="ident">E</span><span class="op">&gt;</span> { <span class="comment">// ... }</span>
<span class="kw">fn</span> <span class="ident">take_future</span>(<span class="ident">future</span>: <span class="kw">impl</span> <span class="ident">Future</span><span class="op">&lt;</span><span class="ident">Output</span> <span class="op">=</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">E</span><span class="op">&gt;</span><span class="op">&gt;</span>) { <span class="comment">/* ... */</span> }
<span class="ident">take_future</span>(<span class="ident">make_try_future</span>().<span class="ident">into_future</span>());</pre></div>
</div><h3 id="method.try_poll_unpin" class="method"><code>pub fn <a href="#method.try_poll_unpin" class="fnname">try_poll_unpin</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;cx: &amp;mut <a class="struct" href="../../futures/task/struct.Context.html" title="struct futures::task::Context">Context</a>&lt;'_&gt;<br>) -&gt; <a class="enum" href="../../futures/task/enum.Poll.html" title="enum futures::task::Poll">Poll</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Ok" title="type futures::future::TryFuture::Ok">Ok</a>, Self::<a class="type" href="../../futures/future/trait.TryFuture.html#associatedtype.Error" title="type futures::future::TryFuture::Error">Error</a>&gt;&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#613-615" title="goto source code">[src]</a></h3><div class="docblock"><p>A convenience method for calling <a href="../../futures/future/trait.TryFuture.html#tymethod.try_poll" title="TryFuture::try_poll"><code>TryFuture::try_poll</code></a> on <a href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="Unpin"><code>Unpin</code></a>
future types.</p>
</div></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-TryFutureExt" class="impl"><code class="in-band">impl&lt;Fut&gt; TryFutureExt for Fut <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Fut: <a class="trait" href="../../futures/future/trait.TryFuture.html" title="trait futures::future::TryFuture">TryFuture</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-TryFutureExt" class="anchor"></a><a class="srclink" href="../../src/futures_util/future/try_future/mod.rs.html#134" title="goto source code">[src]</a></h3><div class="impl-items"></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/futures_util/future/try_future/trait.TryFutureExt.js" async></script></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>