Files
rapr-rs/docs/futures_util/future/trait.FutureExt.html
T
Uttarayan Mondal d5ecda4c73 Initial docs commit
2021-03-15 01:27:34 +05:30

199 lines
78 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="An extension trait for `Future`s that provides a variety of convenient adapters."><meta name="keywords" content="rust, rustlang, rust-lang, FutureExt"><title>futures_util::future::FutureExt - 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_util/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait FutureExt</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.map">map</a><a href="#method.flatten">flatten</a><a href="#method.fuse">fuse</a><a href="#method.map_into">map_into</a><a href="#method.then">then</a><a href="#method.left_future">left_future</a><a href="#method.right_future">right_future</a><a href="#method.into_stream">into_stream</a><a href="#method.flatten_stream">flatten_stream</a><a href="#method.inspect">inspect</a><a href="#method.unit_error">unit_error</a><a href="#method.never_error">never_error</a><a href="#method.poll_unpin">poll_unpin</a><a href="#method.now_or_never">now_or_never</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">futures_util</a>::<wbr><a href="index.html">future</a></p><div id="sidebar-vars" data-name="FutureExt" 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_util</a>::<wbr><a href="index.html">future</a>::<wbr><a class="trait" href="">FutureExt</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/future/mod.rs.html#123-610" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait FutureExt: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> {
fn <a href="#method.map" class="fnname">map</a>&lt;U, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</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_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Map&lt;Fut, F&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;Map&lt;Fut, F&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>) -&gt; U,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.map_into" class="fnname">map_into</a>&lt;U&gt;(self) -&gt; <a class="struct" href="../../futures_util/future/struct.MapInto.html" title="struct futures_util::future::MapInto">MapInto</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_util/future/struct.MapInto.html" title="struct futures_util::future::MapInto">MapInto</a>&lt;Fut, T&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.MapInto.html" title="struct futures_util::future::MapInto">MapInto</a>&lt;Fut, T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, IntoFn&lt;T&gt;&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, IntoFn&lt;T&gt;&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</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;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.then" class="fnname">then</a>&lt;Fut, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures_util/future/struct.Then.html" title="struct futures_util::future::Then">Then</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_util/future/struct.Then.html" title="struct futures_util::future::Then">Then</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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.Then.html" title="struct futures_util::future::Then">Then</a>&lt;Fut1, Fut2, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Flatten&lt;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut1, F&gt;, Fut2&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;Flatten&lt;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut1, F&gt;, Fut2&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>) -&gt; Fut,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fut: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.left_future" class="fnname">left_future</a>&lt;B&gt;(self) -&gt; <a class="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;Self, B&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="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;A, B&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;A, B&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;A, B&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;A: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&lt;Output = A::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt;,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = A::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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;B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&lt;Output = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.right_future" class="fnname">right_future</a>&lt;A&gt;(self) -&gt; <a class="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;A, 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="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;A, B&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;A, B&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;A, B&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;A: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&lt;Output = A::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt;,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = A::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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;A: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&lt;Output = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.into_stream" class="fnname">into_stream</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.IntoStream.html" title="struct futures_util::future::IntoStream">IntoStream</a>&lt;Self&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.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.flatten" class="fnname">flatten</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.Flatten.html" title="struct futures_util::future::Flatten">Flatten</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_util/future/struct.Flatten.html" title="struct futures_util::future::Flatten">Flatten</a>&lt;F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.Flatten.html" title="struct futures_util::future::Flatten">Flatten</a>&lt;F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Flatten&lt;F, &lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;Flatten&lt;F, &lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.flatten_stream" class="fnname">flatten_stream</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.FlattenStream.html" title="struct futures_util::future::FlattenStream">FlattenStream</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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>: <a class="trait" href="../../futures_util/stream/trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.fuse" class="fnname">fuse</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.Fuse.html" title="struct futures_util::future::Fuse">Fuse</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_util/future/struct.Fuse.html" title="struct futures_util::future::Fuse">Fuse</a>&lt;Fut&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.Fuse.html" title="struct futures_util::future::Fuse">Fuse</a>&lt;Fut&gt;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = Fut::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.inspect" class="fnname">inspect</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures_util/future/struct.Inspect.html" title="struct futures_util::future::Inspect">Inspect</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_util/future/struct.Inspect.html" title="struct futures_util::future::Inspect">Inspect</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.Inspect.html" title="struct futures_util::future::Inspect">Inspect</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Map&lt;Fut, InspectFn&lt;F&gt;&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;Map&lt;Fut, InspectFn&lt;F&gt;&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.unit_error" class="fnname">unit_error</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.UnitError.html" title="struct futures_util::future::UnitError">UnitError</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_util/future/struct.UnitError.html" title="struct futures_util::future::UnitError">UnitError</a>&lt;Fut&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.UnitError.html" title="struct futures_util::future::UnitError">UnitError</a>&lt;Fut&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, OkFn&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, OkFn&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.never_error" class="fnname">never_error</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.NeverError.html" title="struct futures_util::future::NeverError">NeverError</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_util/future/struct.NeverError.html" title="struct futures_util::future::NeverError">NeverError</a>&lt;Fut&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.NeverError.html" title="struct futures_util::future::NeverError">NeverError</a>&lt;Fut&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, OkFn&lt;<a class="type" href="../../futures_util/never/type.Never.html" title="type futures_util::never::Never">Never</a>&gt;&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, OkFn&lt;<a class="type" href="../../futures_util/never/type.Never.html" title="type futures_util::never::Never">Never</a>&gt;&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.poll_unpin" class="fnname">poll_unpin</a>(&amp;mut self, cx: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&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>,
{ ... }
<div class="item-spacer"></div> fn <a href="#method.now_or_never" class="fnname">now_or_never</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&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.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
}</pre></div><div class="docblock"><p>An extension trait for <code>Future</code>s that provides a variety of convenient
adapters.</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.map" class="method"><code>fn <a href="#method.map" class="fnname">map</a>&lt;U, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</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_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Map&lt;Fut, F&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;Map&lt;Fut, F&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>) -&gt; U,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <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 class="srclink" href="../../src/futures_util/future/future/mod.rs.html#146-152" title="goto source code">[src]</a></h3><div class="docblock"><p>Map this futures output to a different type, returning a new future of
the resulting type.</p>
<p>This function is similar to the <code>Option::map</code> or <code>Iterator::map</code> where
it will change the type of the underlying future. This is useful to
chain along a computation once a future has been resolved.</p>
<p>Note that this function consumes the receiving future and returns a
wrapped version of it, similar to the existing <code>map</code> methods in the
standard library.</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">FutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</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">map</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">new_future</span>.<span class="kw">await</span>, <span class="number">4</span>);</pre></div>
</div><h3 id="method.map_into" class="method"><code>fn <a href="#method.map_into" class="fnname">map_into</a>&lt;U&gt;(self) -&gt; <a class="struct" href="../../futures_util/future/struct.MapInto.html" title="struct futures_util::future::MapInto">MapInto</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_util/future/struct.MapInto.html" title="struct futures_util::future::MapInto">MapInto</a>&lt;Fut, T&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.MapInto.html" title="struct futures_util::future::MapInto">MapInto</a>&lt;Fut, T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, IntoFn&lt;T&gt;&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, IntoFn&lt;T&gt;&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</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;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <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 class="srclink" href="../../src/futures_util/future/future/mod.rs.html#159-165" title="goto source code">[src]</a></h3><div class="docblock"><p>Map this futures output to a different type, returning a new future of
the resulting type.</p>
<p>This function is equivalent to calling <code>map(Into::into)</code> but allows naming
the return type.</p>
</div><h3 id="method.then" class="method"><code>fn <a href="#method.then" class="fnname">then</a>&lt;Fut, F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures_util/future/struct.Then.html" title="struct futures_util::future::Then">Then</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_util/future/struct.Then.html" title="struct futures_util::future::Then">Then</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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.Then.html" title="struct futures_util::future::Then">Then</a>&lt;Fut1, Fut2, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Flatten&lt;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut1, F&gt;, Fut2&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;Flatten&lt;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut1, F&gt;, Fut2&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>) -&gt; Fut,<br>&nbsp;&nbsp;&nbsp;&nbsp;Fut: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <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 class="srclink" href="../../src/futures_util/future/future/mod.rs.html#191-198" title="goto source code">[src]</a></h3><div class="docblock"><p>Chain on a computation for when a future finished, passing the result of
the future to the provided closure <code>f</code>.</p>
<p>The returned value of the closure must implement the <code>Future</code> trait
and can represent some more work to be done before the composed future
is finished.</p>
<p>The closure <code>f</code> is only run <em>after</em> successful completion of the <code>self</code>
future.</p>
<p>Note that this function consumes the receiving future 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">FutureExt</span>;
<span class="kw">let</span> <span class="ident">future_of_1</span> <span class="op">=</span> <span class="kw">async</span> { <span class="number">1</span> };
<span class="kw">let</span> <span class="ident">future_of_4</span> <span class="op">=</span> <span class="ident">future_of_1</span>.<span class="ident">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="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_of_4</span>.<span class="kw">await</span>, <span class="number">4</span>);</pre></div>
</div><h3 id="method.left_future" class="method"><code>fn <a href="#method.left_future" class="fnname">left_future</a>&lt;B&gt;(self) -&gt; <a class="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;Self, B&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="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;A, B&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;A, B&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;A, B&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;A: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&lt;Output = A::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt;,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = A::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&lt;Output = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <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 class="srclink" href="../../src/futures_util/future/future/mod.rs.html#222-228" title="goto source code">[src]</a></h3><div class="docblock"><p>Wrap this future in an <code>Either</code> future, making it the left-hand variant
of that <code>Either</code>.</p>
<p>This can be used in combination with the <code>right_future</code> method to write <code>if</code>
statements that evaluate to different futures in different branches.</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">FutureExt</span>;
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">6</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">if</span> <span class="ident">x</span> <span class="op">&lt;</span> <span class="number">10</span> {
<span class="kw">async</span> { <span class="bool-val">true</span> }.<span class="ident">left_future</span>()
} <span class="kw">else</span> {
<span class="kw">async</span> { <span class="bool-val">false</span> }.<span class="ident">right_future</span>()
};
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="bool-val">true</span>);</pre></div>
</div><h3 id="method.right_future" class="method"><code>fn <a href="#method.right_future" class="fnname">right_future</a>&lt;A&gt;(self) -&gt; <a class="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;A, 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="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;A, B&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;A, B&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="enum" href="../../futures_util/future/enum.Either.html" title="enum futures_util::future::Either">Either</a>&lt;A, B&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;A: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&lt;Output = A::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt;,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = A::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;A: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&lt;Output = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <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 class="srclink" href="../../src/futures_util/future/future/mod.rs.html#252-258" title="goto source code">[src]</a></h3><div class="docblock"><p>Wrap this future in an <code>Either</code> future, making it the right-hand variant
of that <code>Either</code>.</p>
<p>This can be used in combination with the <code>left_future</code> method to write <code>if</code>
statements that evaluate to different futures in different branches.</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">FutureExt</span>;
<span class="kw">let</span> <span class="ident">x</span> <span class="op">=</span> <span class="number">6</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">if</span> <span class="ident">x</span> <span class="op">&gt;</span> <span class="number">10</span> {
<span class="kw">async</span> { <span class="bool-val">true</span> }.<span class="ident">left_future</span>()
} <span class="kw">else</span> {
<span class="kw">async</span> { <span class="bool-val">false</span> }.<span class="ident">right_future</span>()
};
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="bool-val">false</span>);</pre></div>
</div><h3 id="method.into_stream" class="method"><code>fn <a href="#method.into_stream" class="fnname">into_stream</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.IntoStream.html" title="struct futures_util::future::IntoStream">IntoStream</a>&lt;Self&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.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/future/mod.rs.html#278-283" title="goto source code">[src]</a></h3><div class="docblock"><p>Convert this future into a single element stream.</p>
<p>The returned stream contains single success if this future resolves to
success or single error if this future resolves into error.</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">FutureExt</span>;
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">stream</span>::<span class="ident">StreamExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="number">17</span> };
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">future</span>.<span class="ident">into_stream</span>();
<span class="kw">let</span> <span class="ident">collected</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">collect</span>().<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">collected</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="number">17</span>]);</pre></div>
</div><h3 id="method.flatten" class="method"><code>fn <a href="#method.flatten" class="fnname">flatten</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.Flatten.html" title="struct futures_util::future::Flatten">Flatten</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_util/future/struct.Flatten.html" title="struct futures_util::future::Flatten">Flatten</a>&lt;F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.Flatten.html" title="struct futures_util::future::Flatten">Flatten</a>&lt;F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Flatten&lt;F, &lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;Flatten&lt;F, &lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <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 class="srclink" href="../../src/futures_util/future/future/mod.rs.html#307-314" title="goto source code">[src]</a></h3><div class="docblock"><p>Flatten the execution of this future when the output of this
future is itself another future.</p>
<p>This can be useful when combining futures together to flatten the
computation out the final result.</p>
<p>This method is roughly equivalent to <code>self.then(|x| x)</code>.</p>
<p>Note that this function consumes the receiving future 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">FutureExt</span>;
<span class="kw">let</span> <span class="ident">nested_future</span> <span class="op">=</span> <span class="kw">async</span> { <span class="kw">async</span> { <span class="number">1</span> } };
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">nested_future</span>.<span class="ident">flatten</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future</span>.<span class="kw">await</span>, <span class="number">1</span>);</pre></div>
</div><h3 id="method.flatten_stream" class="method"><code>fn <a href="#method.flatten_stream" class="fnname">flatten_stream</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.FlattenStream.html" title="struct futures_util::future::FlattenStream">FlattenStream</a>&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>: <a class="trait" href="../../futures_util/stream/trait.Stream.html" title="trait futures_util::stream::Stream">Stream</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <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 class="srclink" href="../../src/futures_util/future/future/mod.rs.html#341-347" 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-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">FutureExt</span>;
<span class="kw">use</span> <span class="ident">futures</span>::<span class="ident">stream</span>::{<span class="self">self</span>, <span class="ident">StreamExt</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="kw">let</span> <span class="ident">future_of_a_stream</span> <span class="op">=</span> <span class="kw">async</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">flatten_stream</span>();
<span class="kw">let</span> <span class="ident">list</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="kw">_</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">stream</span>.<span class="ident">collect</span>().<span class="kw">await</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">list</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.fuse" class="method"><code>fn <a href="#method.fuse" class="fnname">fuse</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.Fuse.html" title="struct futures_util::future::Fuse">Fuse</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_util/future/struct.Fuse.html" title="struct futures_util::future::Fuse">Fuse</a>&lt;Fut&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.Fuse.html" title="struct futures_util::future::Fuse">Fuse</a>&lt;Fut&gt;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = Fut::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/future/mod.rs.html#365-371" title="goto source code">[src]</a></h3><div class="docblock"><p>Fuse a future such that <code>poll</code> will never again be called once it has
completed. This method can be used to turn any <code>Future</code> into a
<code>FusedFuture</code>.</p>
<p>Normally, once a future has returned <code>Poll::Ready</code> from <code>poll</code>,
any further calls could exhibit bad behavior such as blocking
forever, panicking, never returning, etc. If it is known that <code>poll</code>
may be called too often then this method can be used to ensure that it
has defined semantics.</p>
<p>If a <code>fuse</code>d future is <code>poll</code>ed after having returned <code>Poll::Ready</code>
previously, it will return <code>Poll::Pending</code>, from <code>poll</code> again (and will
continue to do so for all future calls to <code>poll</code>).</p>
<p>This combinator will drop the underlying future as soon as it has been
completed to ensure resources are reclaimed as soon as possible.</p>
</div><h3 id="method.inspect" class="method"><code>fn <a href="#method.inspect" class="fnname">inspect</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../../futures_util/future/struct.Inspect.html" title="struct futures_util::future::Inspect">Inspect</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_util/future/struct.Inspect.html" title="struct futures_util::future::Inspect">Inspect</a>&lt;Fut, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.Inspect.html" title="struct futures_util::future::Inspect">Inspect</a>&lt;Fut, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Map&lt;Fut, InspectFn&lt;F&gt;&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;Map&lt;Fut, InspectFn&lt;F&gt;&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>),<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <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 class="srclink" href="../../src/futures_util/future/future/mod.rs.html#391-397" title="goto source code">[src]</a></h3><div class="docblock"><p>Do something with the output of a future before passing it on.</p>
<p>When using futures, youll often chain several of them together. While
working on such code, you might want to check out whats happening at
various parts in the pipeline, without consuming the intermediate
value. To do that, insert a call to <code>inspect</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">FutureExt</span>;
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="kw">async</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</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="number">1</span>);</pre></div>
</div><h3 id="method.unit_error" class="method"><code>fn <a href="#method.unit_error" class="fnname">unit_error</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.UnitError.html" title="struct futures_util::future::UnitError">UnitError</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_util/future/struct.UnitError.html" title="struct futures_util::future::UnitError">UnitError</a>&lt;Fut&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.UnitError.html" title="struct futures_util::future::UnitError">UnitError</a>&lt;Fut&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, OkFn&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, OkFn&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/future/mod.rs.html#541-546" title="goto source code">[src]</a></h3><div class="docblock"><p>Turns a <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html"><code>Future&lt;Output = T&gt;</code></a> into a
<a href="../../futures_util/future/trait.TryFuture.html"><code>TryFuture&lt;Ok = T, Error = ()</code>&gt;</a>.</p>
</div><h3 id="method.never_error" class="method"><code>fn <a href="#method.never_error" class="fnname">never_error</a>(self) -&gt; <a class="struct" href="../../futures_util/future/struct.NeverError.html" title="struct futures_util::future::NeverError">NeverError</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_util/future/struct.NeverError.html" title="struct futures_util::future::NeverError">NeverError</a>&lt;Fut&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;Fut&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="../../futures_util/future/struct.NeverError.html" title="struct futures_util::future::NeverError">NeverError</a>&lt;Fut&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, OkFn&lt;<a class="type" href="../../futures_util/never/type.Never.html" title="type futures_util::never::Never">Never</a>&gt;&gt;: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;<a class="struct" href="../../futures_util/future/struct.Map.html" title="struct futures_util::future::Map">Map</a>&lt;Fut, OkFn&lt;<a class="type" href="../../futures_util/never/type.Never.html" title="type futures_util::never::Never">Never</a>&gt;&gt; as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::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="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/future/mod.rs.html#550-555" title="goto source code">[src]</a></h3><div class="docblock"><p>Turns a <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html"><code>Future&lt;Output = T&gt;</code></a> into a
<a href="../../futures_util/future/trait.TryFuture.html"><code>TryFuture&lt;Ok = T, Error = Never</code>&gt;</a>.</p>
</div><h3 id="method.poll_unpin" class="method"><code>fn <a href="#method.poll_unpin" class="fnname">poll_unpin</a>(&amp;mut self, cx: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&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/future/mod.rs.html#558-563" title="goto source code">[src]</a></h3><div class="docblock"><p>A convenience for calling <code>Future::poll</code> on <code>Unpin</code> future types.</p>
</div><h3 id="method.now_or_never" class="method"><code>fn <a href="#method.now_or_never" class="fnname">now_or_never</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&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.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a class="srclink" href="../../src/futures_util/future/future/mod.rs.html#596-609" title="goto source code">[src]</a></h3><div class="docblock"><p>Evaluates and consumes the future, returning the resulting output if
the future is ready after the first call to <code>Future::poll</code>.</p>
<p>If <code>poll</code> instead returns <code>Poll::Pending</code>, <code>None</code> is returned.</p>
<p>This method is useful in cases where immediacy is more important than
waiting for a result. It is also convenient for quickly obtaining
the value of a future that is known to always resolve immediately.</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">ready</span>, <span class="ident">future</span>::<span class="ident">pending</span>};
<span class="kw">let</span> <span class="ident">future_ready</span> <span class="op">=</span> <span class="ident">ready</span>(<span class="string">&quot;foobar&quot;</span>);
<span class="kw">let</span> <span class="ident">future_pending</span> <span class="op">=</span> <span class="ident">pending</span>::<span class="op">&lt;</span><span class="kw-2">&amp;</span><span class="lifetime">&#39;static</span> <span class="ident">str</span><span class="op">&gt;</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future_ready</span>.<span class="ident">now_or_never</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;foobar&quot;</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future_pending</span>.<span class="ident">now_or_never</span>(), <span class="prelude-val">None</span>);</pre></div>
<p>In cases where it is absolutely known that a future should always
resolve immediately and never return <code>Poll::Pending</code>, this method can
be combined with <code>expect()</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">future_ready</span> <span class="op">=</span> <span class="ident">ready</span>(<span class="string">&quot;foobar&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">future_ready</span>.<span class="ident">now_or_never</span>().<span class="ident">expect</span>(<span class="string">&quot;Future not ready&quot;</span>), <span class="string">&quot;foobar&quot;</span>);</pre></div>
</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-FutureExt" class="impl"><code class="in-band">impl&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; <a class="trait" href="../../futures_util/future/trait.FutureExt.html" title="trait futures_util::future::FutureExt">FutureExt</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,&nbsp;</span></code><a href="#impl-FutureExt" class="anchor"></a><a class="srclink" href="../../src/futures_util/future/future/mod.rs.html#119" 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/trait.FutureExt.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_util"></div>
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>