<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.8.5">Jekyll</generator><link href="https://rust-lang-nursery.github.io/futures-rs/feed.xml" rel="self" type="application/atom+xml" /><link href="https://rust-lang-nursery.github.io/futures-rs/" rel="alternate" type="text/html" /><updated>2020-01-20T08:05:41+00:00</updated><id>https://rust-lang-nursery.github.io/futures-rs/feed.xml</id><title type="html">Futures-rs</title><subtitle>Zero-cost asynchronous programming in Rust</subtitle><entry><title type="html">Compatibility Layer</title><link href="https://rust-lang-nursery.github.io/futures-rs/blog/2019/04/18/compatibility-layer.html" rel="alternate" type="text/html" title="Compatibility Layer" /><published>2019-04-18T00:00:00+00:00</published><updated>2019-04-18T00:00:00+00:00</updated><id>https://rust-lang-nursery.github.io/futures-rs/blog/2019/04/18/compatibility-layer</id><content type="html" xml:base="https://rust-lang-nursery.github.io/futures-rs/blog/2019/04/18/compatibility-layer.html">&lt;h1 id=&quot;futures-01-compatibility-layer&quot;&gt;Futures 0.1 Compatibility Layer&lt;/h1&gt;

&lt;p&gt;Rust’s futures ecosystem is currently split in two: On the one hand we have the vibrant ecosystem built around &lt;a href=&quot;https://docs.rs/futures&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; with its many libraries working on stable Rust and on the other hand there’s the unstable &lt;a href=&quot;https://doc.rust-lang.org/nightly/std/future/&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; ecosystem with support for the ergonomic and powerful &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt;&lt;/code&gt;/&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;k&quot;&gt;await&lt;/span&gt;&lt;/code&gt; language feature. To bridge the gap between these two worlds we have introduced a compatibility layer as part of the &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; extension to &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future&lt;/span&gt;&lt;/code&gt;.  This blog post aims to give an overview over how to use it.&lt;/p&gt;

&lt;h2 id=&quot;cargotoml&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Cargo&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.toml&lt;/span&gt;&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;The compatibility layer can be enabled by setting the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt; feature in your &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Cargo&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.toml&lt;/span&gt;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-toml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;py&quot;&gt;futures-preview&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;version&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.3.0-alpha.14&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;features&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[&quot;compat&quot;]&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To use &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;/code&gt; together in a single project, we can make use of the &lt;a href=&quot;https://doc.rust-lang.org/nightly/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml&quot;&gt;new cargo feature for renaming dependencies&lt;/a&gt;. Why? Because, even though the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;/code&gt; crate is called &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt; on crates.io, it’s lib name is also &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;/code&gt;. By renaming &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;/code&gt; version 0.1 to &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures01&lt;/span&gt;&lt;/code&gt;, we can avoid a name collision:&lt;/p&gt;

&lt;div class=&quot;language-toml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;[dependencies]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;futures01&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;futures&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;version&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;optional&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Note: Renaming the crate is only required if you specify it as a dependency.  If your project only depends on Tokio and thus only indirectly on &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;/code&gt;, then no renaming is required.&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;async-functions-on-01-executors&quot;&gt;Async functions on 0.1 executors&lt;/h2&gt;

&lt;p&gt;The compatibility layer makes it possible to run &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;/code&gt; futures on executors built for &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;/code&gt;. This makes it for instance possible to run futures created via &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt;&lt;/code&gt;/&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;k&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;/code&gt; on Tokio’s executor. Here’s how this looks like:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;#![feature(async_await,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;await_macro,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;futures_api)]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FutureExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TryFutureExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;future03&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Running on the pool&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;future01&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;future03&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;.unit_error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;.boxed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;.compat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;tokio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future01&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Turning a &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;/code&gt; future into a 0.1 future requires three steps:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;First, the future needs to be a &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/future/trait.TryFuture.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;TryFuture&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;, i.e. a future with &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;. If your future isn’t a &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;TryFuture&lt;/span&gt;&lt;/code&gt; yet, you can quickly make it one using the &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/future/trait.FutureExt.html#method.unit_error&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;unit_error&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; combinator which wraps the output in a &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Next, the future needs to be &lt;a href=&quot;https://doc.rust-lang.org/nightly/std/marker/trait.Unpin.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Unpin&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;. If your future isn’t &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Unpin&lt;/span&gt;&lt;/code&gt; yet, you can use the &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/future/trait.FutureExt.html#method.boxed&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;boxed&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; combinator which wraps the future in a &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Pin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The final step is to call the &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/future/trait.TryFutureExt.html#method.compat&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; combinator which wraps the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;/code&gt; future into a 0.1 future that can run on any 0.1 executor.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;01-futures-in-async-functions&quot;&gt;0.1 futures in async functions&lt;/h2&gt;

&lt;p&gt;The conversion from a 0.1 future to a &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;/code&gt; future also works via a &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/compat/trait.Future01CompatExt.html#method.compat&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; combinator method:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;compat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Future01CompatExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;future03&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;future01&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.compat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It converts a 0.1 &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Future&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Item&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Error&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt; into a &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;/code&gt; &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Future&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;streams-and-sinks&quot;&gt;Streams and Sinks&lt;/h2&gt;

&lt;p&gt;Converting between 0.1 and 0.3 streams and sinks are possible via the &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/prelude/trait.TryStreamExt.html#method.compat&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;TryStreamExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/compat/trait.Stream01CompatExt.html#method.compat&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;Stream01CompatExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/prelude/trait.SinkExt.html#method.compat&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;SinkExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/compat/trait.Sink01CompatExt.html#method.sink_compat&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;Sink01CompatExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sink_compat&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; methods. These combinators work analogously to their future equivalents.&lt;/p&gt;

&lt;h2 id=&quot;spawning&quot;&gt;Spawning&lt;/h2&gt;

&lt;p&gt;Finally from the core &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt; feature, there’s also conversions between futures 0.1 &lt;a href=&quot;https://docs.rs/futures/0.1.25/futures/future/trait.Executor.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Executor&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; trait and futures 0.3 &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/task/trait.Spawn.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Spawn&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; trait. Again, these function near identically to the futures compatibility functions with &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/task/trait.SpawnExt.html#method.compat&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;SpawnExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/compat/trait.Executor01CompatExt.html#tymethod.compat&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;Executor01CompatExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; providing the conversions in each direction.&lt;/p&gt;

&lt;h2 id=&quot;async-io&quot;&gt;Async IO&lt;/h2&gt;

&lt;p&gt;With futures 0.1 IO was almost exclusively provided by Tokio, this was reflected in the core IO traits being provided by &lt;a href=&quot;https://docs.rs/tokio-io/&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;tokio&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;io&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;. With 0.3 instead the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;/code&gt; crate is providing these core abstractions along with generic utilities that work with them. To convert between these traits you can enable the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt; feature in your &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Cargo&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.toml&lt;/span&gt;&lt;/code&gt; (this will implicitly enable the base &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt; feature as well):&lt;/p&gt;

&lt;div class=&quot;language-toml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;py&quot;&gt;futures-preview&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;version&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.3.0-alpha.14&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;features&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[&quot;io-compat&quot;]&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This provides the 4 expected conversions: &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/io/trait.AsyncReadExt.html#method.compat&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;AsyncReadExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/compat/trait.AsyncRead01CompatExt.html#tymethod.compat&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;AsyncRead01CompatExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; to convert between &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/io/trait.AsyncRead.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AsyncRead&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://docs.rs/tokio-io/0.1.10/tokio_io/trait.AsyncRead.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;tokio&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AsyncRead&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;; and &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/io/trait.AsyncWriteExt.html#method.compat_write&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;AsyncWriteExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;compat_write&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/compat/trait.AsyncWrite01CompatExt.html#tymethod.compat&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;AsyncWrite01CompatExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;compat&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; to convert between &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.14/futures/io/trait.AsyncWrite.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AsyncWrite&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://docs.rs/tokio-io/0.1.10/tokio_io/trait.AsyncWrite.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;tokio&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AsyncWrite&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;The compatibility layer offers conversions in both directions and thus enables gradual migrations and experiments with &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future&lt;/span&gt;&lt;/code&gt;. With that it manages to bridge the gap between the futures 0.1 and futures 0.3 ecosystems.&lt;/p&gt;

&lt;p&gt;Finally a self contained example that shows using futures 0.1 based &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;hyper&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;tokio&lt;/span&gt;&lt;/code&gt; with a &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;/code&gt; async/await layer in between:&lt;/p&gt;

&lt;div class=&quot;language-toml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;[dependencies]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;futures-preview&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;version&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.3.0-alpha.14&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;features&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[&quot;io-compat&quot;]&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;hyper&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.12.25&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;tokio&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.1.16&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;pin-utils&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;0.1.0-alpha.4&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;#![feature(async_await,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;await_macro,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;futures_api)]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;
  &lt;span class=&quot;nn&quot;&gt;compat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Future01CompatExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Stream01CompatExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AsyncWrite01CompatExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;nn&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FutureExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TryFutureExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;nn&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AsyncWriteExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nn&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;StreamExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pin_utils&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pin_mut&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;future03&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;http://httpbin.org/ip&quot;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.parse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;hyper&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;res&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.compat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;{}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.into_body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.compat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;nd&quot;&gt;pin_mut!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stdout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;tokio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;stdout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.compat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;chunk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stdout&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.write_all&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;chunk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;nf&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(())&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

    &lt;span class=&quot;nn&quot;&gt;tokio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future03&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.map_err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;panic!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;{}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.boxed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.compat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Special thanks goes to the main authors of the compatibility layer:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.github.com/tinaun&quot;&gt;@tinaun&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.github.com/Nemo157&quot;&gt;@Nemo157&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.github.com/cramertj&quot;&gt;@cramertj&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.github.com/LucioFranco&quot;&gt;@LucioFranco&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Josef Brandl</name></author><summary type="html">Futures 0.1 Compatibility Layer</summary></entry><entry><title type="html">Futures 0.3.0-alpha.4</title><link href="https://rust-lang-nursery.github.io/futures-rs/blog/2018/09/02/futures-0.3.0-alpha.4.html" rel="alternate" type="text/html" title="Futures 0.3.0-alpha.4" /><published>2018-09-02T00:00:00+00:00</published><updated>2018-09-02T00:00:00+00:00</updated><id>https://rust-lang-nursery.github.io/futures-rs/blog/2018/09/02/futures-0.3.0-alpha.4</id><content type="html" xml:base="https://rust-lang-nursery.github.io/futures-rs/blog/2018/09/02/futures-0.3.0-alpha.4.html">&lt;p&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;/code&gt; requires a recent nightly (2018-08-31 or newer):&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;rustup update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;futures-test&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;With &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;/code&gt; we’re releasing a new independent crate called
&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;/code&gt; (under the name &lt;a href=&quot;https://crates.io/crates/futures-test-preview&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; on crates.io).
The crate contains various testing utilities that were previously only used
internally in the futures crate. We polished them and made them more ergonomic
to use and are now releasing them as a public standalone crate. What’s a little
different compared to the other crates that comprise futures-rs is that this
one is meant to be used as a dev dependency when implementing custom futures.
So, unlike the other crates, its content is not reexported from the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;/code&gt;
facade.&lt;/p&gt;

&lt;h3 id=&quot;testing-without-futures-test&quot;&gt;Testing without &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;Before getting into the details of &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;/code&gt;, it’s useful to go over a
basic technique for testing asynchronous code that may not be known to everyone.&lt;/p&gt;

&lt;p&gt;A lot of the time you don’t care about all the details of how some async
operation executes, just that it performs a certain task. In these cases you
can simply use an async block run via &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.4/futures/executor/fn.block_on.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;executor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;block_on&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; and
have all your assertions in there. Here’s a quick example:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;some_operation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;F&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;FnMut&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;F&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cm&quot;&gt;/* Some IO stuff */&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cm&quot;&gt;/* Some more IO */&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;cm&quot;&gt;/* ... */&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;#[test]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;test_some_operation&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;executor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;block_on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;values&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[];&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;some_operation&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.push&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)));&lt;/span&gt;
        &lt;span class=&quot;nd&quot;&gt;assert_eq!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nd&quot;&gt;assert_eq!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;test-contexts&quot;&gt;Test &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt;&lt;/code&gt;s&lt;/h3&gt;

&lt;p&gt;While you can get a long way by just defining and running async tests via
&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;block_on&lt;/span&gt;&lt;/code&gt;, sometimes you need to be able to inspect what is happening more
precisely. E.g. when testing &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.4/futures/future/trait.FutureExt.html#method.fuse&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;FutureExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fuse&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; we want to check that after
it completes, &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;/code&gt; correctly returns &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pending&lt;/span&gt;&lt;/code&gt; on subsequent calls.
However, to call &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;/code&gt; we need to somehow acquire a &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt;&lt;/code&gt;.
&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test&lt;/span&gt;&lt;/code&gt; makes this easy. It provides you with all sorts of useful contexts
depending on what you are testing. You have two choices to make when you want to
create a context:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;What should happen when a future calls &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.waker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.wake&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt;?&lt;/li&gt;
  &lt;li&gt;What should happen when a future calls &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.spawner&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.spawn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt;?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For both of these there are two very basic implementations provided: panicking
and noop (short for “no operation”). Sometimes this is all you need. For example
when testing &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;FutureExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fuse&lt;/span&gt;&lt;/code&gt; we use &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.4/futures_test/task/fn.panic_context.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;futures_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;panic_context&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;
which gives a context that will panic on either operation:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;#![feature(pin,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;arbitrary_self_types,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;futures_api)]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FutureExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;panic_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;#[test]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;fuse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;future&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;i32&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.fuse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;panic_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.poll_unpin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.is_ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.poll_unpin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.is_pending&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;wakecounter&quot;&gt;&lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.4/futures_test/task/struct.WakeCounter.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;WakeCounter&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;One slightly more specialized &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Wake&lt;/span&gt;&lt;/code&gt; implementation is to count how
many times a task has been woken. This has been used to check that
&lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.4/futures/future/struct.AbortHandle.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AbortHandle&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; correctly awakens a waiting task when it is aborted. You can
see from this example that setting up a context with this implementation is
slightly more work. We start with a basic &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;panic_context&lt;/span&gt;&lt;/code&gt;, then swap out the
waker with one provided by the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;WakeCounter&lt;/span&gt;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;nd&quot;&gt;#![feature(pin,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;arbitrary_self_types,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;futures_api)]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oneshot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;abortable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Aborted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FutureExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;panic_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;WakeCounter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;#[test]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;abortable_awakens&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a_rx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;oneshot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;abortable_rx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;abort_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;abortable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a_rx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;wake_counter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;WakeCounter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;panic_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.with_waker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wake_counter&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.local_waker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;assert_eq!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;wake_counter&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;nd&quot;&gt;assert_eq!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pending&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;abortable_rx&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.poll_unpin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;nd&quot;&gt;assert_eq!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;wake_counter&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;abort_handle&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.abort&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;nd&quot;&gt;assert_eq!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;wake_counter&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;nd&quot;&gt;assert_eq!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Aborted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;abortable_rx&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.poll_unpin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There are some other implementations provided, take a look in the
&lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.4/futures_test/task/index.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;futures_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;task&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; module docs for more info.&lt;/p&gt;

&lt;h3 id=&quot;futuretestext&quot;&gt;&lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.4/futures_test/future/trait.FutureTestExt.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;FutureTestExt&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Along with the context utilities there are some more test specific combinators
provided. These come on an additional &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;FutureTestExt&lt;/span&gt;&lt;/code&gt; trait. For now there are
three provided:&lt;/p&gt;

&lt;dl&gt;
  &lt;dt&gt;&lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.4/futures_test/future/trait.FutureTestExt.html#method.assert_unmoved&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;assert_unmoved&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/dt&gt;
  &lt;dd&gt;When writing custom futures that wrap other futures you want to be sure that
they’re not accidentally moved after they were polled because that’s not
allowed. This combinator can create a future that can detect such accidental
moves.&lt;/dd&gt;
  &lt;dt&gt;&lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.4/futures_test/future/trait.FutureTestExt.html#method.pending_once&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;pending_once&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/dt&gt;
  &lt;dd&gt;When testing, a lot of the time you will be working with instantly ready
futures like &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt; or &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;. Frequently you need to
have a future that actually acts like a future. This combinator will return
&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pending&lt;/span&gt;&lt;/code&gt; once and instantly wake its task to emulate a real async
operation.&lt;/dd&gt;
  &lt;dt&gt;&lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.4/futures_test/future/trait.FutureTestExt.html#method.run_in_background&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;run_in_background&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/dt&gt;
  &lt;dd&gt;Sometimes you just want to run some future to completion and not care
about the details. This will spin up a dedicated executor on a background
thread to run it to completion for you.&lt;/dd&gt;
&lt;/dl&gt;

&lt;h3 id=&quot;assert_stream_&quot;&gt;&lt;a href=&quot;https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.4/futures_test/index.html#macros&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;assert_stream_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*!&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;The final testing utility is trio of macros for working with streams. Together,
these macros allow you to poll a stream one poll at a time and ensure it
behaves exactly as you imagined:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;#![feature(async_await,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;futures_api,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;pin)]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FutureTestExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;assert_stream_pending&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;assert_stream_next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;assert_stream_done&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pin_utils&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pin_mut&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;once&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.pending_once&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;pin_mut!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;assert_stream_pending!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;assert_stream_next!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;assert_stream_done!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;improvements-to-come&quot;&gt;Improvements to come&lt;/h3&gt;

&lt;p&gt;The work on this crate is not done. We already have some ideas for other useful
testing utilities. If you have existing utilities that you’re using in your
project or ideas about what would be useful to you &lt;a href=&quot;https://github.com/rust-lang-nursery/futures-rs/issues/1169&quot;&gt;please let us know&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;further-changes&quot;&gt;Further changes&lt;/h2&gt;

&lt;p&gt;A complete list of changes can be found in our &lt;a href=&quot;https://github.com/rust-lang-nursery/futures-rs/blob/master/CHANGELOG.md&quot;&gt;changelog&lt;/a&gt;.&lt;/p&gt;</content><author><name>Wim Looman</name></author><summary type="html">0.3.0-alpha.4 requires a recent nightly (2018-08-31 or newer): $ rustup update</summary></entry><entry><title type="html">Fahrenheit</title><link href="https://rust-lang-nursery.github.io/futures-rs/blog/2018/08/17/toykio.html" rel="alternate" type="text/html" title="Fahrenheit" /><published>2018-08-17T00:00:00+00:00</published><updated>2018-08-17T00:00:00+00:00</updated><id>https://rust-lang-nursery.github.io/futures-rs/blog/2018/08/17/toykio</id><content type="html" xml:base="https://rust-lang-nursery.github.io/futures-rs/blog/2018/08/17/toykio.html">&lt;blockquote&gt;
  &lt;p&gt;Note: fahrenheit was previously called “toykio”, but it caused &lt;a href=&quot;https://www.reddit.com/r/rust/comments/97zzig/toykio_and_futures_03/&quot;&gt;great confusion&lt;/a&gt; amongst reddit users.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this blog post I’d like to present &lt;a href=&quot;https://github.com/polachok/fahrenheit&quot;&gt;fahrenheit&lt;/a&gt;, a simple futures executor intended for learning about how executors with an event loop work. Fahrenheit only provides a very minimal feature set: An event loop and TCP streams and listeners. However, it turns out that due to the fact that futures are composable, this is enough to build complex clients and servers.&lt;/p&gt;

&lt;p&gt;In the following, I’d like to give you a quick overview of fahrenheit’s components.&lt;/p&gt;

&lt;h2 id=&quot;asynctcpstream&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncTcpStream&lt;/span&gt;&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;Fahrenheit defines the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncTcpStream&lt;/span&gt;&lt;/code&gt; type, a newtype wrapper around &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;TcpStream&lt;/span&gt;&lt;/code&gt; from the standard library. Just like in std, the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;connect&lt;/span&gt;&lt;/code&gt; function opens a connection, and sets the socket to non-blocking mode. This means that the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nf&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nf&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt; methods will return immediately, either with data or an error. If there’s not enough data (for reads) or buffer space (for writes) available, a special kind of error - &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;WouldBlock&lt;/span&gt;&lt;/code&gt; - is returned. We’ll discuss how to handle it in the next section.&lt;/p&gt;

&lt;h2 id=&quot;asyncread--asyncwrite&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncRead&lt;/span&gt;&lt;/code&gt; &amp;amp; &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncWrite&lt;/span&gt;&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncRead&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncWrite&lt;/span&gt;&lt;/code&gt; traits are the foundation of all I/O futures. The &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncReadExt&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncWriteExt&lt;/span&gt;&lt;/code&gt;
extension methods (like &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;write_all&lt;/span&gt;&lt;/code&gt;) are built on top of them. These traits provide a way to connect futures to an event loop while keeping them independent from any particular event loop implementation.&lt;/p&gt;

&lt;p&gt;Let’s take a look at the &lt;a href=&quot;https://github.com/polachok/fahrenheit/blob/futures-0.3/src/async_tcp_stream.rs#L42&quot;&gt;AsyncRead&lt;/a&gt; implementation for &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncTcpStream&lt;/span&gt;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;impl&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AsyncRead&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AsyncTcpStream&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;poll_read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nf&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)),&lt;/span&gt;
            &lt;span class=&quot;nf&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ref&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.kind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;ErrorKind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WouldBlock&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;c&quot;&gt;// Get TcpStream file descriptor&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.as_raw_fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;waker&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.waker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

                &lt;span class=&quot;n&quot;&gt;REACTOR&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.with&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reactor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reactor&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.add_read_interest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;waker&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.clone&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()));&lt;/span&gt;

                &lt;span class=&quot;nn&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pending&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;nf&quot;&gt;Err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;panic!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;error {:?}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;It tries to perform a read on the underlying &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;TcpStream&lt;/span&gt;&lt;/code&gt; and if the read succeeds, the slice will be filled with data. If however the read fails with a &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;WouldBlock&lt;/span&gt;&lt;/code&gt; error, then it registers the current task’s waker so that it gets awoken when the data becomes available. More about this in the next section.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;https://github.com/polachok/fahrenheit/blob/futures-0.3/src/async_tcp_stream.rs#L61&quot;&gt;AsyncWrite&lt;/a&gt; implementation does something analogous for writes.&lt;/p&gt;

&lt;h2 id=&quot;event-loop&quot;&gt;Event loop&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://github.com/polachok/fahrenheit/blob/futures-0.3/src/lib.rs#L101&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;EventLoop&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;
(often also called “reactor”) is the core of the executor. It is defined like this:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InnerEventLoop&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RefCell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BTreeMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RawFd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Waker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RefCell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BTreeMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RawFd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Waker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Cell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;usize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;wait_queue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RefCell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BTreeMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;TaskId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;run_queue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RefCell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;VecDeque&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Wakeup&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;/code&gt; are &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;BTreeMaps&lt;/span&gt;&lt;/code&gt; which map file descriptors to wakers.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;wait_queue&lt;/span&gt;&lt;/code&gt; stores blocked tasks which wait for an event&lt;/li&gt;
  &lt;li&gt;and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;run_queue&lt;/span&gt;&lt;/code&gt; stores wake-up notifications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The event loop provides methods to &lt;a href=&quot;https://github.com/polachok/fahrenheit/blob/futures-0.3/src/lib.rs#L126&quot;&gt;register&lt;/a&gt; (and remove) interest in read and write events. Let’s look at what &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;add_read_interest&lt;/span&gt;&lt;/code&gt; does:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;add_read_interest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RawFd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;waker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Waker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.read&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.borrow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.contains_key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.read&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.borrow_mut&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.insert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;waker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But it just inserts &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;waker&lt;/span&gt;&lt;/code&gt; into the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;/code&gt; map! So where does all the magic happen?
In the &lt;a href=&quot;https://github.com/polachok/fahrenheit/blob/futures-0.3/src/lib.rs#L188&quot;&gt;main loop&lt;/a&gt;.
The event loop is called a loop for a reason. Let’s take a look:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;loop&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;// Event loop iteration timeout. If no descriptor is ready we continue iterating&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeval&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeval&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;tv_sec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;tv_usec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;// Initialize fd_sets (file descriptor sets)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;read_fds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd_set&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;mem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;zeroed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;write_fds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd_set&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;mem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;zeroed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;FD_ZERO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;read_fds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;FD_ZERO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;write_fds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Woah, woah, a lot of &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;k&quot;&gt;unsafe&lt;/span&gt;&lt;/code&gt; here! Well, don’t worry, it’s just how C FFI works. We need to initialize some C structures, a timeout and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;fd_set&lt;/span&gt;&lt;/code&gt;s. They will be passed to the select(2) function later.&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;c&quot;&gt;// Add read interests to read fd_sets&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.read&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.borrow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.keys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;FD_SET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;read_fds&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd_set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nfds&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;cmp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nfds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;// Add write interests to write fd_sets&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.write&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.borrow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.keys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;FD_SET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;write_fds&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd_set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;nfds&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;cmp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nfds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Here we add file descriptors from our &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;write&lt;/span&gt;&lt;/code&gt; maps from before to the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;fd_set&lt;/span&gt;&lt;/code&gt;s.&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;c&quot;&gt;// `select` will block until some event happens on the fds or the timeout triggers&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rv&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;select&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;nfds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;read_fds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;write_fds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;ptr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;null_mut&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;// Don't care for errors&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rv&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;nd&quot;&gt;panic!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;select()&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rv&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;nd&quot;&gt;debug!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;timeout&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;nd&quot;&gt;debug!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;data available on {} fds&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Finally we call &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;select&lt;/span&gt;&lt;/code&gt; with arguments we prepared earlier. &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nf&quot;&gt;select&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt; accepts 3 fd_sets (we ignore the third for this example) and a timeout and returns something non-zero in case one (or more) of the file descriptors in the sets are ready. We should then go and find which one it was!&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;c&quot;&gt;// Check which fd it was and put appropriate future on run queue&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;waker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.read&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.borrow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.iter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is_set&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;FD_ISSET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;read_fds&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd_set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is_set&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;waker&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.wake&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;// Same for write&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;waker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.write&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.borrow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.iter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is_set&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;unsafe&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;FD_ISSET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;write_fds&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd_set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is_set&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;waker&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.wake&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;We go through our maps again and check if they’re set (ready) in fd_sets. When they are, we
call &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;wake&lt;/span&gt;&lt;/code&gt; on their associated wakers, which in turn puts &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Wakeup&lt;/span&gt;&lt;/code&gt; events on the ready-to-run queue.&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tasks_done&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Vec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;// Now pop tasks from the run queue and poll them&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wakeup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.run_queue&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.borrow_mut&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.pop_front&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ref&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.wait_queue&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.borrow_mut&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.get_mut&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wakeup&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;c&quot;&gt;// If a task returns `Poll::Ready`, we're done with it&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wakeup&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.waker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.is_ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;tasks_done&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.push&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wakeup&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;// Remove completed tasks&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tasks_done&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.wait_queue&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.borrow_mut&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.remove&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;// Stop the loop if there are no more tasks in the `wait_queue`&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;py&quot;&gt;.wait_queue&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.borrow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.is_empty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;We drain the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;run_queue&lt;/span&gt;&lt;/code&gt;, retrieve the task index on the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;wait_queue&lt;/span&gt;&lt;/code&gt; and poll the tasks. Ready (done) tasks are removed from the wait_queue.&lt;/p&gt;

&lt;h2 id=&quot;the-life-of-the-future&quot;&gt;The life of the future&lt;/h2&gt;

&lt;p&gt;In this section, I’d like to recap how a future (let’s take &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-doc/0.3.0-alpha.2/futures/io/struct.Read.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Read&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;
 for example) is executed on the event loop:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;first it’s created using &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-doc/0.3.0-alpha.2/futures/io/trait.AsyncReadExt.html#method.read&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nf&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;
 method on AsyncTcpStream. This method is implemented for all types that implement &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncRead&lt;/span&gt;&lt;/code&gt; trait.&lt;/li&gt;
  &lt;li&gt;then it’s spawned on the executor, using either &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nf&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt; or &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nf&quot;&gt;spawn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt; method&lt;/li&gt;
  &lt;li&gt;the executor calls &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nf&quot;&gt;poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt; method on the future. &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;/code&gt; &lt;a href=&quot;https://rust-lang-nursery.github.io/futures-doc/0.3.0-alpha.2/src/futures_util/io/read.rs.html#28&quot;&gt;implementation&lt;/a&gt;
 for &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Read&lt;/span&gt;&lt;/code&gt; calls &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nf&quot;&gt;poll_read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt; on the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncTcpStream&lt;/span&gt;&lt;/code&gt;, which registers its interest in &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;readable&lt;/span&gt;&lt;/code&gt; events&lt;/li&gt;
  &lt;li&gt;when an event occurs, future is polled again. This cycle is repeated until future is ready.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;thank-you&quot;&gt;Thank you&lt;/h2&gt;
&lt;p&gt;Thanks to all futures team, and specially &lt;a href=&quot;https://github.com/aturon&quot;&gt;@aturon&lt;/a&gt; for encouragement and &lt;a href=&quot;https://github.com/MajorBreakfast&quot;&gt;@MajorBreakfast&lt;/a&gt; for edits.&lt;/p&gt;

&lt;p&gt;That’s all for today! You can find fahrenheit on &lt;a href=&quot;https://github.com/polachok/fahrenheit/tree/futures-0.3&quot;&gt;github&lt;/a&gt; and &lt;a href=&quot;https://crates.io/crates/fahrenheit&quot;&gt;crates.io&lt;/a&gt;. Happy hacking!&lt;/p&gt;</content><author><name>Alexander Polakov</name></author><summary type="html">Note: fahrenheit was previously called “toykio”, but it caused great confusion amongst reddit users.</summary></entry><entry><title type="html">Futures 0.3.0-alpha.3</title><link href="https://rust-lang-nursery.github.io/futures-rs/blog/2018/08/15/futures-0.3.0-alpha.3.html" rel="alternate" type="text/html" title="Futures 0.3.0-alpha.3" /><published>2018-08-15T00:00:00+00:00</published><updated>2018-08-15T00:00:00+00:00</updated><id>https://rust-lang-nursery.github.io/futures-rs/blog/2018/08/15/futures-0.3.0-alpha.3</id><content type="html" xml:base="https://rust-lang-nursery.github.io/futures-rs/blog/2018/08/15/futures-0.3.0-alpha.3.html">&lt;p&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;/code&gt; requires a recent nightly (2018-08-13 or newer):&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;rustup update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;compatibility-layer&quot;&gt;Compatibility layer&lt;/h2&gt;

&lt;p&gt;A compatibility layer between 0.3 and 0.1 was developed. It is now possible to convert an 0.3 future into an 0.1 future and vice versa. Similar conversions for streams and sinks are also supported. Additionally, it is now possible to run 0.3 futures and async functions on Tokio’s executor. We have a dedicated blog post coming up that explains this in more detail.&lt;/p&gt;

&lt;h2 id=&quot;spawning&quot;&gt;Spawning&lt;/h2&gt;

&lt;h3 id=&quot;spawn-trait&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Spawn&lt;/span&gt;&lt;/code&gt; trait&lt;/h3&gt;

&lt;p&gt;The &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Executor&lt;/span&gt;&lt;/code&gt; trait is now called &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Spawn&lt;/span&gt;&lt;/code&gt;. We chose to rename the trait to &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Spawn&lt;/span&gt;&lt;/code&gt; because the functionality exposed by this trait is not the ability to execute, but the ability to spawn.&lt;/p&gt;

&lt;p&gt;As a consequence of this renaming, some functions on &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt;&lt;/code&gt; were adjusted:&lt;/p&gt;
&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;impl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local_waker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LocalWaker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;spawner&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'a&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Spawn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;spawner&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Spawn&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;with_spawner&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Sp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Spawn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'b&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;spawner&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'b&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Sp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;spawn-macros&quot;&gt;Spawn macros&lt;/h3&gt;

&lt;p&gt;This release of futures-rs introduces the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nd&quot;&gt;spawn!&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nd&quot;&gt;spawn_with_handle!&lt;/span&gt;&lt;/code&gt; macros for use in async functions, closures and blocks. Both macros let you spawn a task that polls the given future to completion. The task is spawned via the current context’s spawner.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nd&quot;&gt;spawn!&lt;/span&gt;&lt;/code&gt; lets you spawn futures with &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;#![feature(async_await,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;await_macro,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;futures_api)]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;spawn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;spawn!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nd&quot;&gt;spawn_with_handle!&lt;/span&gt;&lt;/code&gt; lets you spawn futures with any &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Send&lt;/span&gt;&lt;/code&gt; type and returns a future that resolves to the output of the spawned future:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;spawn_with_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;join_handle&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;spawn_with_handle!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;join_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nd&quot;&gt;spawn!&lt;/span&gt;&lt;/code&gt; is slightly cheaper than &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nd&quot;&gt;spawn_with_handle!&lt;/span&gt;&lt;/code&gt; since it doesn’t need to provide a way to get the output.&lt;/p&gt;

&lt;p&gt;Should spawning fail, a &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;SpawnError&lt;/span&gt;&lt;/code&gt; error is returned which contains information about why it failed.&lt;/p&gt;

&lt;p&gt;So what futures can be spawned? There are some requirements: The future needs to be &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nb&quot;&gt;Send&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nv&quot;&gt;'static&lt;/span&gt;&lt;/code&gt; and the output needs to be &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nb&quot;&gt;Send&lt;/span&gt;&lt;/code&gt;. Here’s why:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;The &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nv&quot;&gt;'static&lt;/span&gt;&lt;/code&gt; lifetime means that the future cannot contain any non-static references. This is required so that the spawned task can be run independently to the task that spawns it.&lt;/li&gt;
  &lt;li&gt;The &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nb&quot;&gt;Send&lt;/span&gt;&lt;/code&gt; bounds mean that the future and its output can be sent to other threads. This is required so that multithreaded executors can run the spawned task on any thread they choose.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: You can still execute non-&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nb&quot;&gt;Send&lt;/span&gt;&lt;/code&gt;, non-&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nv&quot;&gt;'static&lt;/span&gt;&lt;/code&gt; futures concurrently via the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nd&quot;&gt;join!&lt;/span&gt;&lt;/code&gt; macro.&lt;/p&gt;

&lt;h3 id=&quot;spawn-methods&quot;&gt;Spawn methods&lt;/h3&gt;

&lt;p&gt;For use outside of async functions, there’s also something new: The &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;SpawnExt&lt;/span&gt;&lt;/code&gt; trait. It provides the methods &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;spawn&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;spawn_with_handle&lt;/span&gt;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SpawnExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;// spawn()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;spawner&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.spawn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;// spawn_with_handle()&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;join_handle&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;spawner&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.spawn_with_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Inside &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;/code&gt;, you can use these methods by accessing the context’s spawner via &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;spawner&lt;/span&gt;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PinMut&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.spawner&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.spawn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;the-plan-spawn-with-dyn-future&quot;&gt;The plan: &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;spawn&lt;/span&gt;&lt;/code&gt; with &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Future&lt;/span&gt;&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;We plan to eventually replace &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;SpawnExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;spawn&lt;/span&gt;&lt;/code&gt; with &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;Spawn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;spawn&lt;/span&gt;&lt;/code&gt;. This method will live directly in the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Spawn&lt;/span&gt;&lt;/code&gt; trait defined in libcore. It’s signature will look like this:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;spawn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Future&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Send&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;'static&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SpawnError&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This method can’t be implemented just yet due to compiler limitations:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Arbitrary self types are currently not object-safe: &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;Future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;/code&gt; uses &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;PinMut&lt;/span&gt;&lt;/code&gt; as arbitrary self type. This unfortunately makes it impossible to create trait objects for &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Future&lt;/span&gt;&lt;/code&gt;. Therefore, &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nb&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Future&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Future&lt;/span&gt;&lt;/code&gt; are &lt;em&gt;currently&lt;/em&gt; not supported.&lt;/li&gt;
  &lt;li&gt;Unsized rvalues are not yet available: Trait objects (&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Trait&lt;/span&gt;&lt;/code&gt;) are &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sized&lt;/span&gt;&lt;/code&gt; because the size of a trait object depends on the size of the concrete type behind it and can therefore only be known at runtime. Currently we often use &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nb&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dyn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Trait&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt; which stores the trait object on the heap to circumvent that. The unsized rvalues feature will make it possible to store &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sized&lt;/span&gt;&lt;/code&gt; types on the stack.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To circumvent these limitations, we currently have &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;FutureObj&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;Spawn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;spawn_obj&lt;/span&gt;&lt;/code&gt;. These are, however, just a temporary solution until we can introduce the planned &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;spawn&lt;/span&gt;&lt;/code&gt; method. The planned &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;spawn&lt;/span&gt;&lt;/code&gt; method will make it possible to have one fewer heap allocation because the future is kept on the stack for as long as possible.&lt;/p&gt;

&lt;h2 id=&quot;pin-utils-crate&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;utils&lt;/span&gt;&lt;/code&gt; crate&lt;/h2&gt;

&lt;p&gt;The pin macros now live in their own crate, the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;pin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;utils&lt;/span&gt;&lt;/code&gt; crate. The macros are general purpose and can be used in any project that uses the pinning API.&lt;/p&gt;

&lt;p&gt;The crate includes the macros for (un)pin projections &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nd&quot;&gt;unsafe_pinned!&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nd&quot;&gt;unsafe_unpinned!&lt;/span&gt;&lt;/code&gt; and the macro for stack pinning &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nd&quot;&gt;pin_mut!&lt;/span&gt;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;foo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Foo&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;pin_mut!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;foo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;// PinMut&amp;lt;Foo&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Version &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;/code&gt; is now available on &lt;a href=&quot;https://crates.io/crates/pin-utils&quot;&gt;crates.io&lt;/a&gt; and the API docs are available on &lt;a href=&quot;https://docs.rs/pin-utils&quot;&gt;docs.rs&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;further-changes&quot;&gt;Further changes&lt;/h2&gt;

&lt;p&gt;A complete list of changes can be found in our &lt;a href=&quot;https://github.com/rust-lang-nursery/futures-rs/blob/master/CHANGELOG.md&quot;&gt;changelog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A big thanks goes to every one who contributed to this release! This includes &lt;a href=&quot;https://github.com/tinaun&quot;&gt;@tinaun&lt;/a&gt;, &lt;a href=&quot;https://github.com/Nemo157&quot;&gt;@Nemo157&lt;/a&gt;, &lt;a href=&quot;https://github.com/cramertj&quot;&gt;@cramertj&lt;/a&gt; and &lt;a href=&quot;https://github.com/MajorBreakfast&quot;&gt;@MajorBreakfast&lt;/a&gt; and our new contributors &lt;a href=&quot;https://github.com/gbonik&quot;&gt;@gbonik&lt;/a&gt; and &lt;a href=&quot;https://github.com/dbcfd&quot;&gt;@dbcfd&lt;/a&gt;!&lt;/p&gt;</content><author><name>Josef Brandl</name></author><summary type="html">0.3.0-alpha.3 requires a recent nightly (2018-08-13 or newer): $ rustup update</summary></entry><entry><title type="html">Futures 0.3.0-alpha.2</title><link href="https://rust-lang-nursery.github.io/futures-rs/blog/2018/07/30/futures-0.3.0-alpha.2.html" rel="alternate" type="text/html" title="Futures 0.3.0-alpha.2" /><published>2018-07-30T00:00:00+00:00</published><updated>2018-07-30T00:00:00+00:00</updated><id>https://rust-lang-nursery.github.io/futures-rs/blog/2018/07/30/futures-0.3.0-alpha.2</id><content type="html" xml:base="https://rust-lang-nursery.github.io/futures-rs/blog/2018/07/30/futures-0.3.0-alpha.2.html">&lt;p&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;/code&gt; requires a recent nightly (2018-07-29 or newer):&lt;/p&gt;
&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;rustup update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;whats-new&quot;&gt;What’s new?&lt;/h2&gt;

&lt;h3 id=&quot;refined-definition-for-task&quot;&gt;Refined definition for “task”&lt;/h3&gt;

&lt;p&gt;The documentation for the &lt;a href=&quot;https://doc.rust-lang.org/nightly/std/task/trait.Executor.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Executor&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; trait was updated. It now defines a “task executor” like this:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Futures are polled until completion by tasks, a kind of lightweight “thread”. A &lt;em&gt;task executor&lt;/em&gt; is responsible for the creation of these tasks and the coordination of their execution on real operating system threads. In particular, whenever a task signals that it can make further progress via a wake-up notification, it is the responsibility of the task executor to put the task into a queue to continue executing it, i.e. polling the future in it, later.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The notable difference to before is that the term “task” no longer refers to the future that the task runs. Instead, from now on, the term “task” only refers to the concept of a lightweight thread, a kind of thread that doesn’t directly correspond to a thread provided by the operating system. This concept is sometimes also referred to as “green thread” - We, however, do not use either of these terms because they tend to cause confusion with real operating system threads. Instead, we call this concept a “task” and the thing that runs them a “task executor” or often just “executor”.&lt;/p&gt;

&lt;h3 id=&quot;try-impl-for-poll&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Try&lt;/span&gt;&lt;/code&gt; impl for &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/code&gt; now implements the &lt;a href=&quot;https://doc.rust-lang.org/std/ops/trait.Try.html&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Try&lt;/span&gt;&lt;/code&gt;&lt;/a&gt; trait. This means you can now do this:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PinMut&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;// Returns early if there's an error&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ok_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;ready!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;// Returns early if the value is pending&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;// Or short:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ok_value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;ready!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Additionally &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Try&lt;/span&gt;&lt;/code&gt; was also implemented for &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/code&gt; to make the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;/code&gt;-operator useful in &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;nn&quot;&gt;Stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;/code&gt; implentations:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;poll_next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PinMut&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.poll_next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;// Returns early if there's an error&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ok_item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;ready!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;poll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;// Returns early if the value is pending&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;// Or short:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ok_item&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;ready!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.poll_next&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can find additional details about this change in the &lt;a href=&quot;https://github.com/rust-lang/rust/pull/52721&quot;&gt;pull request&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;changes-to-futures-rs&quot;&gt;Changes to futures-rs&lt;/h3&gt;

&lt;p&gt;We revived the &lt;a href=&quot;https://github.com/rust-lang-nursery/futures-rs/blob/master/CHANGELOG.md&quot;&gt;changelog&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;No major changes happened to the futures crate since the last release. There were, however, numerous little changes. Take a look at the &lt;a href=&quot;https://github.com/rust-lang-nursery/futures-rs/blob/master/CHANGELOG.md&quot;&gt;changelog&lt;/a&gt; to get an overview.&lt;/p&gt;

&lt;h2 id=&quot;what-are-we-currently-working-on&quot;&gt;What are we currently working on?&lt;/h2&gt;

&lt;h3 id=&quot;compatiblity-layer-for-futures-01&quot;&gt;Compatiblity layer for futures 0.1&lt;/h3&gt;

&lt;p&gt;We are currently working on an officially supported compatibility layer between &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;/code&gt;. This shim will make it possible to mix &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;/code&gt; futures with those from the 0.3 branch. The plan is to make it possible to use crates from the existing futures &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;/code&gt; ecosystem together with async functions and futures from the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;/code&gt; crate. Additionally, this compatibility layer will also make it possible to gradually migrate exisiting applications and libraries to &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;/code&gt;. If you’re curious, take a look the &lt;a href=&quot;https://github.com/rust-lang-nursery/futures-rs/pull/1119&quot;&gt;compatibility layer PR&lt;/a&gt; and the &lt;a href=&quot;https://github.com/rust-lang-nursery/net-wg/issues/26&quot;&gt;issue&lt;/a&gt; in the net-wg repository.&lt;/p&gt;</content><author><name>Josef Brandl</name></author><summary type="html">0.3.0-alpha.2 requires a recent nightly (2018-07-29 or newer): $ rustup update</summary></entry><entry><title type="html">Futures 0.3.0-alpha.1</title><link href="https://rust-lang-nursery.github.io/futures-rs/blog/2018/07/19/futures-0.3.0-alpha.1.html" rel="alternate" type="text/html" title="Futures 0.3.0-alpha.1" /><published>2018-07-19T17:00:00+00:00</published><updated>2018-07-19T17:00:00+00:00</updated><id>https://rust-lang-nursery.github.io/futures-rs/blog/2018/07/19/futures-0.3.0-alpha.1</id><content type="html" xml:base="https://rust-lang-nursery.github.io/futures-rs/blog/2018/07/19/futures-0.3.0-alpha.1.html">&lt;p&gt;Welcome to the inaugural post of the new futures-rs blog!&lt;/p&gt;

&lt;p&gt;After several months of work, we’re happy to announce an &lt;em&gt;alpha&lt;/em&gt; release of the new edition of futures-rs, version 0.3. The immediate goal of this work is to support async/await notation (&lt;a href=&quot;http://aturon.github.io/2018/04/24/async-borrowing/&quot;&gt;with borrowing&lt;/a&gt;) in Rust itself, which has entailed significant changes to the futures crate.&lt;/p&gt;

&lt;h2 id=&quot;tldr&quot;&gt;TL;DR&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;The 0.3.0-alpha.1 release is available in the new &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt; family of crates.&lt;/li&gt;
  &lt;li&gt;It requires a nightly compiler, and works with rustc’s new support for async/await notation.&lt;/li&gt;
  &lt;li&gt;Tokio and Hyper support is not yet available for 0.3.0-alpha.1, but that’s the next area of work.&lt;/li&gt;
  &lt;li&gt;Neither the futures crate nor async/await notation will be stabilized for the initial release of the Rust 2018 Edition.&lt;/li&gt;
  &lt;li&gt;Futures 0.1 continues to be maintained and is the primary way to write production async code today. We plan to continue maintaining 0.1 for some time after 0.3.0 is released, as well.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short, this alpha release sets the stage for kicking off integration and documentation, but is not yet widely usable.&lt;/p&gt;

&lt;h2 id=&quot;the-futures-preview-crate&quot;&gt;The futures-preview crate&lt;/h2&gt;

&lt;p&gt;We’re publishing a 0.3.0-alpha.1 release of futures today, but rather than doing it within the existing &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;/code&gt; crate, we’re publishing within the new &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt; family of crates. This allows us to more clearly signal that this version is a work in progress, and to keep crates.io and docs.rs pages pointing to the 0.1 series.&lt;/p&gt;

&lt;p&gt;In other words:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Futures 0.1 is the production-ready way to use futures today, and is actively maintained.&lt;/li&gt;
  &lt;li&gt;Ongoing work for async/await will live in the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt; crates until it is ready to be promoted to 0.3.0.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;what-is-futures-03&quot;&gt;What is futures 0.3?&lt;/h2&gt;
&lt;h3 id=&quot;asyncawait&quot;&gt;Async/await&lt;/h3&gt;

&lt;p&gt;With futures 0.3 alpha, it is possible to use the new &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt;&lt;/code&gt;/&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;k&quot;&gt;await&lt;/span&gt;&lt;/code&gt; notation that recently landed in nightly:&lt;/p&gt;

&lt;div class=&quot;language-toml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;py&quot;&gt;cargo-features&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[&quot;edition&quot;]&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[package]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;edition&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;2018&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;#![feature(async_await,&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;await_macro)]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;executor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;block_on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::{&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FutureExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nf&quot;&gt;block_on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fut&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;future&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;lazy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(|&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;vec!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shared1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fut&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.shared&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shared2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shared1&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.clone&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;assert_eq!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;await!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shared1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nd&quot;&gt;assert_eq!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nd&quot;&gt;await!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shared2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The notation works as described in &lt;a href=&quot;https://github.com/rust-lang/rfcs/pull/2394&quot;&gt;the corresponding RFC&lt;/a&gt;; more documentation for it is forthcoming. There are several open questions on this notation, but these are largely on hold until we have achieved integration with Tokio and Hyper, at which point more serious code can be written against the library.&lt;/p&gt;

&lt;p&gt;While we had originally hoped to ship async/await notation as part of Rust 2018, there’s no chance at this point of having adequate feedback and confidence to do so in time. However, the &lt;a href=&quot;https://github.com/rust-lang-nursery/net-wg/&quot;&gt;Networking WG&lt;/a&gt; plans to continue pushing hard in this space up to and after the Rust 2018 launch, to provide the strongest story on &lt;em&gt;nightly&lt;/em&gt; Rust that we can, and to get us on a path for stabilization.&lt;/p&gt;

&lt;h3 id=&quot;ecosystem-integration&quot;&gt;Ecosystem integration&lt;/h3&gt;

&lt;p&gt;As of this writing, futures 0.3.0-alpha.1 is not integrated in any way with other libraries like Tokio or Hyper. Achieving such integration is a crucial part of getting real experience with the design and ultimately heading toward stabilization. The Futures Team intends to work closely with the Tokio Team to determine the best way forward here — either a shim crate for compatibility with futures 0.1, or direct integration via a feature-flag.&lt;/p&gt;

&lt;p&gt;This integration is our main next area of work, and we’d love to have help! If you’re interested in getting involved, drop by the #wg-net channel on &lt;a href=&quot;https://discord.gg/rust-lang&quot;&gt;Discord&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;crate-structure-and-relation-to-std&quot;&gt;Crate structure and relation to &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;To support the built-in async/await notation, the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Future&lt;/span&gt;&lt;/code&gt; trait and associated machinery had to &lt;a href=&quot;https://github.com/rust-lang/rfcs/pull/2418&quot;&gt;move into the standard library&lt;/a&gt;. As such, the futures 0.3.0-alpha.1 release just re-exports those definitions, and then adds a host of useful extras, including streams, sinks, I/O traits, and the various combinators.&lt;/p&gt;

&lt;p&gt;The overall organization of the crate is similar to the 0.2 release:&lt;/p&gt;

&lt;dl&gt;
  &lt;dt&gt;&lt;a href=&quot;https://crates.io/crates/futures-core-preview&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;core&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/dt&gt;
  &lt;dd&gt;This crate re-exports the futures-related items from &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;/code&gt;, and defines &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Stream&lt;/span&gt;&lt;/code&gt;, &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;TryFuture&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;TryStream&lt;/span&gt;&lt;/code&gt;.&lt;/dd&gt;
  &lt;dt&gt;&lt;a href=&quot;https://crates.io/crates/futures-executor-preview&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;executor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/dt&gt;
  &lt;dd&gt;This crate provides basic executors (a thread pool and a thread-local executor).&lt;/dd&gt;
  &lt;dt&gt;&lt;a href=&quot;https://crates.io/crates/futures-io-preview&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/dt&gt;
  &lt;dd&gt;This crate defines core traits for I/O.&lt;/dd&gt;
  &lt;dt&gt;&lt;a href=&quot;https://crates.io/crates/futures-sink-preview&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sink&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/dt&gt;
  &lt;dd&gt;This crate defines the core &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Sink&lt;/span&gt;&lt;/code&gt; trait.&lt;/dd&gt;
  &lt;dt&gt;&lt;a href=&quot;https://crates.io/crates/futures-channel-preview&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/dt&gt;
  &lt;dd&gt;This crate defines basic &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Sync&lt;/span&gt;&lt;/code&gt; channels with end points implementing &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Future&lt;/span&gt;&lt;/code&gt;, &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Stream&lt;/span&gt;&lt;/code&gt; or &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Sink&lt;/span&gt;&lt;/code&gt;.&lt;/dd&gt;
  &lt;dt&gt;&lt;a href=&quot;https://crates.io/crates/futures-util-preview&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;util&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/dt&gt;
  &lt;dd&gt;This crate defines a collection of extension traits with useful adapters (aka combinators).&lt;/dd&gt;
  &lt;dt&gt;&lt;a href=&quot;https://crates.io/crates/futures-preview&quot;&gt;&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;futures&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;preview&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;/dt&gt;
  &lt;dd&gt;This crate is a “facade” combining and re-exporting all of the above crates for convenience.&lt;/dd&gt;
&lt;/dl&gt;

&lt;p&gt;You can read more about the rationale for the breakdown into multiple crates in the &lt;a href=&quot;http://aturon.github.io/2018/02/27/futures-0-2-RC/&quot;&gt;0.2 notes&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;changes-from-02&quot;&gt;Changes from 0.2&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Note: Changes between 0.1 and 0.2 are outlined in the &lt;a href=&quot;http://aturon.github.io/2018/02/27/futures-0-2-RC/&quot;&gt;0.2 notes&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Aside from some minor structural changes, there are two major changes from the 0.2 release:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Using pinned types to support borrowing within async blocks.&lt;/li&gt;
  &lt;li&gt;Factoring out the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Error&lt;/span&gt;&lt;/code&gt; type into separate traits (&lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;TryFuture&lt;/span&gt;&lt;/code&gt; and &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;TryStream&lt;/span&gt;&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both of these changes are described and motivated in detail in &lt;a href=&quot;https://github.com/rust-lang/rfcs/pull/2418&quot;&gt;the companion RFC&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The RFC, however, covers only the core &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Future&lt;/span&gt;&lt;/code&gt; trait and executor system. The bulk of the work in 0.3.0-alpha.1 has been pushing through these ideas through the rest of the crates, adapting the combinators and other traits to fit with pinning and the ability to borrow across yield points. For example, the &lt;a href=&quot;https://github.com/rust-lang-nursery/futures-rs/blob/0.3/futures-util/src/io/mod.rs#L67-L74&quot;&gt;revised&lt;/a&gt; &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;AsyncReadExt&lt;/span&gt;&lt;/code&gt; trait now provides a &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;/code&gt; method that operates on borrowed data, just like in the &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;Read&lt;/span&gt;&lt;/code&gt; trait in &lt;code class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;span class=&quot;n&quot;&gt;std&lt;/span&gt;&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;trait&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AsyncReadExt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AsyncRead&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// Tries to read some bytes directly into the given `buf` in asynchronous&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// manner, returning a future type.&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;///&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// The returned future will resolve to the number of bytes read once the read&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;/// operation is completed.&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'a&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'a&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'a&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;u8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Read&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;'a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nn&quot;&gt;Read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;buf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In contrast, the 0.1-style API must operate on &lt;em&gt;owned&lt;/em&gt; buffers, which are threaded through the futures code. You can learn more about how this all works in &lt;a href=&quot;http://aturon.github.io/2018/04/24/async-borrowing/&quot;&gt;this blog post on borrowing and async/await&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;the-road-ahead&quot;&gt;The road ahead&lt;/h2&gt;

&lt;p&gt;While futures 0.3.0-alpha.1 is a major milestone, we still have a &lt;em&gt;ton&lt;/em&gt; of work to do! The immediate next steps include:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Work out the integration story for Tokio, Hyper, and other important crates.&lt;/li&gt;
  &lt;li&gt;Write documentation for async/await notation.&lt;/li&gt;
  &lt;li&gt;Flesh out the migration path from futures 0.1 code.&lt;/li&gt;
  &lt;li&gt;Generally gain experience and feedback using this new design and async/await notation, so that we can get on track for stabilization.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More generally, the futures team plans on communicating via this blog much more regularly about progress and ways to get involved. And now that the alpha is at the door, the broader &lt;a href=&quot;https://github.com/rust-lang-nursery/net-wg/&quot;&gt;Networking WG&lt;/a&gt; is hoping to reboot, bring in a lot more people, and start focusing on ecosystem concerns.&lt;/p&gt;

&lt;p&gt;As always, if you’re interested in getting involved in this space, reach out on #wg-net on &lt;a href=&quot;https://discord.gg/rust-lang&quot;&gt;Discord&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;thank-you&quot;&gt;Thank you!&lt;/h2&gt;

&lt;p&gt;This alpha release is the result of work by a growing set of people contributing to the futures crate (some of whom have joined the team officially):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/aturon&quot;&gt;@aturon&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/cramertj&quot;&gt;@cramertj&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/MajorBreakfast&quot;&gt;@MajorBreakfast&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Nemo157&quot;&gt;@Nemo157&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/ngg&quot;&gt;@ngg&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/tinaun&quot;&gt;@tinaun&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Aaron Turon</name></author><summary type="html">Welcome to the inaugural post of the new futures-rs blog!</summary></entry><entry><title type="html">New Website</title><link href="https://rust-lang-nursery.github.io/futures-rs/blog/2018/07/19/new-website.html" rel="alternate" type="text/html" title="New Website" /><published>2018-07-19T16:00:00+00:00</published><updated>2018-07-19T16:00:00+00:00</updated><id>https://rust-lang-nursery.github.io/futures-rs/blog/2018/07/19/new-website</id><content type="html" xml:base="https://rust-lang-nursery.github.io/futures-rs/blog/2018/07/19/new-website.html">&lt;h2 id=&quot;welcome&quot;&gt;Welcome!&lt;/h2&gt;

&lt;p&gt;Futures-rs now has a website and a logo. We hope you like it! This site contains our brand new blog with which we plan to keep you up-to-date about the project.&lt;/p&gt;

&lt;p&gt;Enjoy reading!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;BTW The logo was inspired by a movie, we’ll leave it up to the reader to guess which one :)&lt;/em&gt;&lt;/p&gt;</content><author><name>Josef Brandl</name></author><summary type="html">Welcome!</summary></entry></feed>