Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add IntoFuture #259

Merged
5 commits merged into from Oct 15, 2019
Merged

add IntoFuture #259

5 commits merged into from Oct 15, 2019

Conversation

yoshuawuyts
Copy link
Contributor

@yoshuawuyts yoshuawuyts commented Sep 28, 2019

Adds the IntoFuture trait, wihch @Nemo157 pointed out would be useful for implementing the "async builder" pattern we used when building Surf.

In the RFC2394 async_await it's also stated that await should call IntoFuture under the hood.

A builtin called await! is added to the compiler. await! can be used to "pause" the computation of the future, yielding control back to the caller. await! takes any expression which implements IntoFuture, and evaluates to a value of the item type that that future has.

This PR doesn't add that functionality to await, but does have the right shape it should take, which allows people to start implementing IntoFuture so that later it will "just work".


cc/ @withoutboats, is what I've said so far about IntoFuture still accurate? I didn't see any mentions that this had been changed in the stabilization report, so does that mean that it means this simply has not been implemented yet?

Screenshot

Screenshot_2019-09-28 async_std future - Rust

Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
@yoshuawuyts yoshuawuyts added the enhancement New feature or request label Sep 28, 2019
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
@ghost
Copy link

ghost commented Oct 6, 2019

Do you think it would make sense to open this PR in the rust-lang/rust repository? :) It seems to me the intention was for this trait to exist in the standard library, but nobody has implemented it there yet.

@yoshuawuyts
Copy link
Contributor Author

@stjepang yeah I think it does. I do think there's value in still merging the PR here though. I'll check with the lang team what they think and if they're okay with it I'll follow up with the PR to std.

@withoutboats
Copy link

@stjepang @yoshuawuyts I think IntoFuture (and making await work with that) would be a great extension, but probably one that would require a (small) RFC.

@yoshuawuyts
Copy link
Contributor Author

There's now a PR to std for this also: rust-lang/rust#65244.

Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
@ghost ghost merged commit 237cfa0 into master Oct 15, 2019
@ghost ghost deleted the into_future branch October 15, 2019 14:03
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants