-
Notifications
You must be signed in to change notification settings - Fork 20
ACP: Add future::ok and future::err #529
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
Comments
These functions can be written as: std::future::ready(Ok(t));
std::future::ready(Err(err)); The upside of
|
@tisonkun Thank you for filing MCP this and tagging me on it. When I filed to add Can you share a bit more about how you're thinking about this space? If we were to add The reason why I'm asking is because there are always more APIs that can be added. There tends to be a pretty high bar for an API to be included in the stdlib. It would be useful to better understand why you believe that these specific APIs are important enough to be included. edit: I realized you wrote: "It can be used as a bare function pointer in combinators." I'm not quite sure what you meant by that. Could you elaborate? |
Thanks for pointing this out @yoshuawuyts and sharing the background of
When filling a parameter accept For example, I've written recently: let mut concurrent_tasks = futures::stream::iter(tasks)
.buffer_by_unordered(total_uncompressed_bytes)
.try_filter_map(futures::future::ok);
Yes. I'd share my current findings and would love to know where I can participate in helping the async WG. We currently have core definitions We have a semi-standard crate futures-rs provides extra definitions like We have more third-party crates that provides runtime-agnostic primitives (mea, flume) that can be analogies to I would expect we bring For combinators, we have iterator combinators and utilities in the core lib, but we leave more complex tools to the ecosystem (itertools, etc.). futures-rs ever hit the combination explosion, as in rust-lang/futures-rs#2755 (combine three monads: list, try, future). So I'm hesitate to redo the same in core lib (this ACP can be considered part of it). However, currently, these utilities are located at For primitives, I have no certain idea. I'd prefer to see them (async Mutex, Condvar, Semaphore, WaitGroup, etc.) in the core lib since they're runtime-agnostic, can be implemented in a determinate way, and we have For IOs and executors abstractions, they are more complex concepts to discuss, so I don't dive into them here. To sum up, I'm looking for a way to help gradually stabilize the good part of async toolchains so that the ecosystem can converge into several base points rather than handling multiple similar abstractions and utilities and adapting their subtle differences. |
cc @rust-lang/wg-async |
Let's close this. We raised this over in the async stream, and nobody much argued against the position that this just doesn't carry its weight, and that if we did this, it would imply wanting |
Uh oh!
There was an error while loading. Please reload this page.
Proposal
Problem statement
We already bring
futures::future::ready
to std. I find it frequent to useok
anderr
also. Perhaps we bring the same to the core lib.Motivating examples or use cases
See as in the solution.
It is currently available in
futures-util
but it'll bring several extra parts. I may consider that the async wg would have a plan for the reasonable state of the final stable separation (cc @taiki-e @nrc @yoshuawuyts).Solution sketch
Alternatives
N/A
Links and related work
Bringing from:
https://github.com/rust-lang/futures-rs/blob/048995af9e6f24de71ac7e009ab2e5f5ac290f48/futures-util/src/future/ready.rs#L52-L82
and expected into after:
https://github.com/rust-lang/rust/blob/aa6f5ab18e67cb815f73e0d53d217bc54b0da924/library/core/src/future/ready.rs#L66-L69
What happens now?
This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.
Possible responses
The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):
Second, if there's a concrete solution:
The text was updated successfully, but these errors were encountered: