Decide on generic-ness of functions like Iterator::try_find
and array::try_map
#85115
Labels
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
array::try_map
tracking issue: #79711Iterator::try_find
tracking issue: #63178try_map
only allows the closure to return aResult
, and has the function also return aResult
.try_find
was added in #63177 allowing the closure to return anyTry
(v1), but the function itself always returned aResult
.With
Try
v2, there's no longer an associated type for theError
type, sotry_find
needs a different approach. #84767 changed it to a bit of a hacky version that's probably not what should be stabilized. And whatever solution is picked should probably be used fortry_map
as well.I think there are two main options:
Result
. This is certainly the easiest option. It's unclear how important supporting other types would be -- this might depend on the error handling WG's work. If it ends up having a not-really-Result
type that's used in some situations, this might be suboptimal..try_find(...)?
wouldn't work, as?
isn't a strong enough context to force any particular family of types.The text was updated successfully, but these errors were encountered: