-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Change array_from_fn
signatures
#90505
Conversation
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
I've seen that nowadays |
After a week without comments, I am assuming that using the |
397d610
to
5167fd6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not prepared to stabilize this instantly with the signature change. This needs to go into nightly with the new signature so that we can get a picture of whether this gives rise to inconvenient inference issues in practical use, or anything else that may come up.
Sigh... Done |
5167fd6
to
d45e0b6
Compare
array_from_fn
featurearray_try_from
signatures
array_try_from
signaturesarray_from_fn
signatures
The usual problem is that an inferred return type is not compatible with I copied over the function signature here into the playground https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=0cdced05401eea1621827f86537ccd18, and sure enough, inference failures:
And, importantly, that's happening despite the explicitly-specified closure type and a fully available return type (no try blocks or IIFEs or similar to confuse it). That It also compiles fine with the approach in #91286: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=3bc991d03ff52c972fc4c3b6dd02c46e (Sorry for not seeing this PR sooner.) |
Thanks for continuing to push these forward, @c410-f3r -- they're critical building blocks and I'd love to see them in stable. |
Superseded by #91286
Implementation
These functions are using the same inner code of other array methods and such feature already ensures a reliable execution.
Signature
Originally, indices returned by the callback were introduced as auxiliary parameters since arrays are hereditary indexed and known at compile-time.
But due to #75644 (comment) and #75644 (comment), no index will be returned to avoid further concerns or discussions.