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 tuple<->array convertions via From
#97594
base: master
Are you sure you want to change the base?
Conversation
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
|
(rust-highfive has picked a reviewer for you, use r? to override) |
|
r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs |
|
@rustbot label -S-waiting-on-review +S-waiting-on-author |
This comment has been minimized.
This comment has been minimized.
|
I've removed
They all basically do the following: fn f() -> Result<(), ()> {
Ok(())?; // <--
Ok(())
}For this to work you need to infer IIRC this is not considered a breaking change per rust rules, because it can be fixed by adding types: fn f() -> Result<(), ()> {
Ok::<_, ()>(())?;
//^^^^^^^^^
Ok(())
}However I'm not sure how widespread this pattern is and if this is worth the potential breakage. |
|
@rustbot ready |
|
|
... with this convertions some tests fail :(
46a44a8
to
156c906
Compare
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
|
ping from triage: What's the status of this PR? |
|
Looks like this is old enough that it pre-dates ACPs, so I'll nominate it for libs-api to say what they want. |
|
@camelid pretty much what the tags say: this is waiting on a |
|
We briefly discussed this in the libs-api meeting, and we were wondering if there are any motivating use cases. |
|
From the top of my head I can't really recall too many specific examples, but I definitely needed this a couple of times. In particular when dealing with different crates where one crate returns colors as (r, g, b, a) but another wants [r, g, b, a]. Similarly for xyz coordinates. Older APIs usually used tuples a lot (including std) because arrays were a lot less powerful (in terms of destructuring for example), but nowadays arrays should be preferred, so you often want to convert. |
|
Any thoughts on how often it's needed as Having |
|
So, I couldn't find the exact use case which caused this PR, going through the chat logs of the time I saw this: But I'm not sure what caused this / what was the context. I would think that the use-case was similar to what @CryZe described — using multiple APIs some of which prefer tuples and some of which prefer arrays. @scottmcm I think that using |
|
@rfcbot merge |
|
Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
|
|
When we discussed this in today's @rust-lang/libs-api meeting, we were happy to see it merged. But also, we wanted to track down whatever issue is causing the spurious suggestions about Also, separate from that, suggestions should be versionsorted (1, 2, 3), not alphabetically sorted (10, 11, 12, 1, 2, ...). |
This PR adds the following impls that convert between homogeneous tuples and arrays of the corresponding lengths:
IMO these are quite uncontroversial but note that they are, just like any other trait impls, insta-stable.