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 |
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