-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Implement Ready::into_inner()
#101189
Implement Ready::into_inner()
#101189
Conversation
r? @scottmcm (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
cb24fa8
to
60d5e69
Compare
60d5e69
to
5ed1787
Compare
Something named r? libs-api |
Ah that's a very good point. I forgot that Ready was Option based. I would offer up the term |
I modeled this very much after Generally speaking in the Either way, personally I would prefer a method that will actually panic in this case. I don't oppose adding a |
Firstly, in my experience of this particular future, I've never needed a Given the panic behavior, |
Seems relatively reasonable to me. It does seem like few cases will know in advance they have a @bors r+ |
…riplett Implement `Ready::into_inner()` Tracking issue: rust-lang#101196. This implements a method to unwrap the value inside a `Ready` outside an async context. See https://docs.rs/futures/0.3.24/futures/future/struct.Ready.html#method.into_inner for previous work. This was discussed in [Zulip beforehand](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/.60Ready.3A.3Ainto_inner.28.29.60): > An example I'm hitting right now: I have a cross-platform library that provides a functions that returns a `Future`. The only reason why it returns a `Future` is because the WASM platform requires it, but the native doesn't, to make a cross-platform API that is equal for all I just return a `Ready` on the native targets. > > Now I would like to expose native-only functions that aren't async, that users can use to avoid having to deal with async when they are targeting native. With `into_inner` that's easily solvable now. > > I want to point out that some internal restructuring could be used to solve that problem too, but in this case it's not that simple, the library uses internal traits that return the `Future` already and playing around with that would introduce unnecessary `cfg` in a lot more places. So it is really only a quality-of-life feature.
Rollup of 6 pull requests Successful merges: - rust-lang#101189 (Implement `Ready::into_inner()`) - rust-lang#101642 (Fix in-place collection leak when remaining element destructor panic) - rust-lang#102489 (Normalize substs before resolving instance in `NoopMethodCall` lint) - rust-lang#102559 (Don't ICE when trying to copy unsized value in const prop) - rust-lang#102568 (Lint against nested opaque types that don't satisfy associated type bounds) - rust-lang#102633 (Fix rustdoc ICE in invalid_rust_codeblocks lint) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…r, r=dtolnay Stabilize `Ready::into_inner()` This PR stabilizes `Ready::into_inner()`. Tracking issue: rust-lang#101196. Implementation PR: rust-lang#101189. Closes rust-lang#101196.
… r=dtolnay Stabilize `Ready::into_inner()` This PR stabilizes `Ready::into_inner()`. Tracking issue: rust-lang#101196. Implementation PR: rust-lang#101189. Closes rust-lang#101196.
Tracking issue: #101196.
This implements a method to unwrap the value inside a
Ready
outside an async context.See https://docs.rs/futures/0.3.24/futures/future/struct.Ready.html#method.into_inner for previous work.
This was discussed in Zulip beforehand: