Skip to content
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 Extend impls for tuples of arity 1 through 12 #132187

Merged
merged 4 commits into from
Dec 7, 2024

Conversation

shahn
Copy link
Contributor

@shahn shahn commented Oct 26, 2024

No description provided.

@rustbot
Copy link
Collaborator

rustbot commented Oct 26, 2024

r? @scottmcm

rustbot has assigned @scottmcm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 26, 2024
@shahn
Copy link
Contributor Author

shahn commented Oct 26, 2024

This was discussed in #85835 (comment) and I want to get that effort started. It's been forever since I contributed to rustc, so please excuse if I did something wrong. If this is deemed OK, I would be happy to follow this up with the same treatmeant for FromIterator and maybe `unzip, too - but those probably deserve their own PR?

@scottmcm scottmcm added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. labels Oct 30, 2024
@scottmcm
Copy link
Member

r? libs-api

@rustbot rustbot assigned dtolnay and unassigned scottmcm Oct 30, 2024
@dtolnay

This comment was marked as outdated.

@dtolnay dtolnay removed the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Oct 30, 2024
@rfcbot

This comment was marked as outdated.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 30, 2024
@dtolnay

This comment was marked as outdated.

@rfcbot

This comment was marked as outdated.

@rfcbot rfcbot removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 30, 2024
@dtolnay
Copy link
Member

dtolnay commented Oct 30, 2024

@rust-lang/libs-api:
@rfcbot fcp merge

Among other things, this feature makes unzip work for larger (and smaller) tuples.
Among other things, this feature makes collect_into (which is still unstable) work for larger tuples.

  fn main() {
      let iter = std::iter::repeat_n(('a', 'b', 'c'), 3);

-     let mut collection = (Vec::new(), (Vec::new(), Vec::new()));
-     iter.map(|(a, b, c)| (a, (b, c))).collect_into(&mut collection);
-     let (va, (vb, vc)) = collection;
+     let mut collections = (Vec::new(), Vec::new(), Vec::new());
+     iter.collect_into(&mut collections);
+     let (va, vb, vc) = collections;
      println!("{:?}\n{:?}\n{:?}", va, vb, vc);
}

@rfcbot
Copy link

rfcbot commented Oct 30, 2024

Team member @dtolnay 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.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 30, 2024
@cuviper
Copy link
Member

cuviper commented Oct 30, 2024

Among other things, this feature makes unzip work for larger (and smaller) tuples.

How so? This doesn't change Iterator::unzip AFAICS, which explicitly operates on pairs -- but either of those pairs could be a nested tuple of arity 1..=12 after this change.

@dtolnay
Copy link
Member

dtolnay commented Oct 30, 2024

You are right. I've updated the motivating use case to use collect_into instead of unzip. Or please let me know if someone knows a better one.

@shahn

This comment was marked as duplicate.

@shahn
Copy link
Contributor Author

shahn commented Oct 31, 2024

I noticed I made a silly mistake, I added tuple impls for not just 12-tuples but 13-tuples accidentally. I am also adding some tests for these impls, but I wonder, is there a good example to verify 13-tuples do not have the Extend impl?

I also want to add the FromIterator<(EA, ...)> for (A, ...) impls. Should these go into a new PR? That would enable this:

    let a = vec![(1, 2, 3), (4, 5, 6), (7, 8, 9)];
    let b: (Vec<_>, Vec<_>, Vec<_>) = a.into_iter().collect();

@shahn
Copy link
Contributor Author

shahn commented Nov 17, 2024

it would be awesome to get your opinion here, @joshtriplett @m-ou-se @BurntSushi - thanks!

@dtolnay dtolnay added the S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). label Nov 21, 2024
@Amanieu Amanieu removed the S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). label Nov 26, 2024
@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Nov 26, 2024
@rfcbot
Copy link

rfcbot commented Nov 26, 2024

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Dec 6, 2024
@rfcbot
Copy link

rfcbot commented Dec 6, 2024

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay
Copy link
Member

dtolnay commented Dec 6, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Dec 6, 2024

📌 Commit 27342cb has been approved by dtolnay

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 6, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 6, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#130209 (Stabilize `std::io::ErrorKind::CrossesDevices`)
 - rust-lang#130254 (Stabilize `std::io::ErrorKind::QuotaExceeded`)
 - rust-lang#132187 (Add Extend impls for tuples of arity 1 through 12)
 - rust-lang#133875 (handle `--json-output` properly)
 - rust-lang#133934 (Do not implement unsafe auto traits for types with unsafe fields)
 - rust-lang#133954 (Hide errors whose suggestions would contain error constants or types)
 - rust-lang#133960 (rustdoc: remove eq for clean::Attributes)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 7, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#130209 (Stabilize `std::io::ErrorKind::CrossesDevices`)
 - rust-lang#130254 (Stabilize `std::io::ErrorKind::QuotaExceeded`)
 - rust-lang#132187 (Add Extend impls for tuples of arity 1 through 12)
 - rust-lang#133875 (handle `--json-output` properly)
 - rust-lang#133934 (Do not implement unsafe auto traits for types with unsafe fields)
 - rust-lang#133954 (Hide errors whose suggestions would contain error constants or types)
 - rust-lang#133960 (rustdoc: remove eq for clean::Attributes)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 7, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#130209 (Stabilize `std::io::ErrorKind::CrossesDevices`)
 - rust-lang#130254 (Stabilize `std::io::ErrorKind::QuotaExceeded`)
 - rust-lang#132187 (Add Extend impls for tuples of arity 1 through 12)
 - rust-lang#133875 (handle `--json-output` properly)
 - rust-lang#133934 (Do not implement unsafe auto traits for types with unsafe fields)
 - rust-lang#133954 (Hide errors whose suggestions would contain error constants or types)
 - rust-lang#133960 (rustdoc: remove eq for clean::Attributes)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit bfbbe95 into rust-lang:master Dec 7, 2024
6 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Dec 7, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 7, 2024
Rollup merge of rust-lang#132187 - shahn:extend_more_tuples, r=dtolnay

Add Extend impls for tuples of arity 1 through 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. to-announce Announce this issue on triage meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants