-
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
Add Ref/RefMut try_map method #118087
base: master
Are you sure you want to change the base?
Add Ref/RefMut try_map method #118087
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
ACPs are the recommended way to get the libs-api team to approve new unstable APIs. I've marked this as waiting-on-team which I believe also is in their queue. (libs-api -- we may want to update the guidance on the linked docs to just require an ACP) |
The motivation is an important part of the ACP. We do need to understand the motivation, ideally with clear use cases, before accepting new (unstable) APIs. |
@GrigorenkoPV any updates on creating the ACP? if you have done so, kindly add it to the pr description. Thanks |
The ACP: rust-lang/libs-team#341 @rustbot review |
b809d3b
to
5ec6988
Compare
Thanks for your work on this @GrigorenkoPV! We would love for this method to be added. @Mark-Simulacrum is there anything else needed here to get it across the finish line? I'd be happy to put some time into this if I can help in any way. |
@stegaBOB this is waiting on the ACP getting merged, so we need to wait fro that and nothing is expected from author or reviewer about it. |
5ec6988
to
59e49ca
Compare
☔ The latest upstream changes (presumably #134052) made this pull request unmergeable. Please resolve the merge conflicts. |
#133567 changed a place in |
59e49ca
to
a8dc530
Compare
A more generalized version of
filter_map
, which allows to return some data on failure.Safety
As far as I can tell,
E
cannot contain any'b
data, so it is impossible to duplicate the&'b [mut]
reference into theRefCell
's data.Other than this
E
, everything is analogous to the already stablefilter_map
.Try
/Residual
I have considered generalizing this to use the
Try
&Residual
just like #79711 does forarray::try_map
, but it does not seem to be possible: we want to essentially.map_err(|e| (orig, e))
but this does not seem to be supported withTry
. (Plus I am not even sure if it is possible to express the fact that&U
inTry::Output
would have to have the same lifetime as the&T
input ofF
.)ACP
As far as I can tell, this is not mandatory, and the implementation is small enough to probably be smaller than the doc I would have to write.rust-lang/libs-team#341