Stream: wg-async-foundations

Topic: IntoFuture


theduke (Sep 21 2019 at 16:14, on Zulip):

The original async/await RFC specifies await (well, the macro variant) to go through a IntoFuture trait (see RFC).

Is there a reason why this wasn't implemented, or is this an oversight?

The context is a blog post which gave me the idea for an IntoFuture trait, but someone pointed out that it actually was already in the RFC.

nikomatsakis (Sep 23 2019 at 12:33, on Zulip):

It was removed at some point, but before I got involved; I believe @boats or @Taylor Cramer could expand.

boats (Sep 23 2019 at 21:44, on Zulip):

We found in futures 0.2 that it was not needed. In 0.1, when future incorporated the error into its type, Result implemented IntoFuture, but in 0.2, there was nothing that did other than futures

Taylor Cramer (Sep 23 2019 at 21:48, on Zulip):

(nit: futures and tuples)

Taylor Cramer (Sep 23 2019 at 21:48, on Zulip):

but yeah, @boats's summary is correct

theduke (Sep 24 2019 at 07:03, on Zulip):

there was nothing that did other than futures

The blog post outlines the use case where I also personally would have wanted this numerous times: being able to .await on a builder type structs, like http/db request builders.

Without this it requires either always calling a finalizer method like .send(), or keeping an Option<MyFuture> on the builder and checking it on every poll.

IntoFuture would be a pretty big ergonomics win.

Last update: Nov 18 2019 at 02:00UTC