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

Implement FromIterator for (impl Default Extend, impl Default Extend) #107462

Merged
merged 2 commits into from
Apr 14, 2024

Conversation

WaffleLapkin
Copy link
Member

Similarly to how #85835 implemented Extend for (impl Extend, impl Extend):

impl<A, B, AE, BE> FromIterator<(AE, BE)> for (A, B)
where
    A: Default   Extend<AE>,
    B: Default   Extend<BE>,
{ ... }

@WaffleLapkin WaffleLapkin 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 Jan 30, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jan 30, 2023

r? @joshtriplett

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 30, 2023
@rustbot

This comment was marked as resolved.

@cuviper
Copy link
Member

cuviper commented Jan 30, 2023

As I mentioned in #85835 (comment), rayon has a parallel version of this here, but it's based on inner FromParallelIterator rather than Default ParallelExtend. I don't think the API allows splitting on FromIterator here though.

A nice benefit is that it composes well, like collecting Option<(A, B)> or Result<(A, B), E>, or nested ((A, B), (C, D)).

@workingjubilee
Copy link
Contributor

r? libs-api

Needs FCP.

@rustbot rustbot assigned m-ou-se and unassigned joshtriplett Oct 28, 2023
@m-ou-se m-ou-se added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). I-libs-api-nominated The issue / PR has been nominated for discussion during a libs-api team meeting. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2024
@the8472
Copy link
Member

the8472 commented Feb 20, 2024

This looks a lot like iterator.unzip. Could it just delegate to that impl?

@Amanieu
Copy link
Member

Amanieu commented Feb 20, 2024

We discussed this in the libs-api meeting today. We're happy to add this, but it should include a doc comment with an example.

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Feb 20, 2024

Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

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 Feb 20, 2024
@Amanieu Amanieu 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. I-libs-api-nominated The issue / PR has been nominated for discussion during a libs-api team meeting. labels Feb 20, 2024
@WaffleLapkin
Copy link
Member Author

@the8472 somehow I've never seen Iterator::unzip, even though it's apparently it existed since forever O_o

Yes, this should be able to use .unzip. Tbh I'm not even sure how useful this is given a method exists...

@cuviper
Copy link
Member

cuviper commented Feb 24, 2024

It still composes better than unzip alone, as I mentioned earlier. For example, you can .collect::<Result<(A, B), E>>() to unzip into types A and B while short-circuiting on error E.

@WaffleLapkin
Copy link
Member Author

Ah, right, makes sense. I'll clean up the PR once the FCP finishes.

@cuviper
Copy link
Member

cuviper commented Feb 24, 2024

@Amanieu was it an accident that you removed FCP labels? It looks like you might have RMW-raced with rfcbot.

@Amanieu Amanieu 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 Feb 24, 2024
@Amanieu
Copy link
Member

Amanieu commented Feb 24, 2024

Oops, I've added them back.

@Amanieu Amanieu added S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. and removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Feb 27, 2024
@BurntSushi
Copy link
Member

@rfcbot concern doc-example

I'm just registering this to make sure this impl gets some docs with an example before it's officially stabilized.

@WaffleLapkin WaffleLapkin removed the needs-fcp This change is insta-stable, so needs a completed FCP to proceed. label Mar 11, 2024
@WaffleLapkin
Copy link
Member Author

@Amanieu @BurntSushi I've pushed a commit with documentation, does it look good? Does it resolve the concern?

@BurntSushi
Copy link
Member

@rfcbot resolve doc-example

@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 Apr 3, 2024
@rfcbot
Copy link

rfcbot commented Apr 3, 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 Apr 13, 2024
@rfcbot
Copy link

rfcbot commented Apr 13, 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.

@dtolnay
Copy link
Member

dtolnay commented Apr 13, 2024

@bors r

@bors
Copy link
Contributor

bors commented Apr 13, 2024

📌 Commit 7b5af57 has been approved by dtolnay

It is now in the queue for this repository.

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 13, 2024
@dtolnay dtolnay assigned dtolnay and unassigned m-ou-se Apr 13, 2024
@bors
Copy link
Contributor

bors commented Apr 14, 2024

⌛ Testing commit 7b5af57 with merge f3c6608...

@bors
Copy link
Contributor

bors commented Apr 14, 2024

☀️ Test successful - checks-actions
Approved by: dtolnay
Pushing f3c6608 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 14, 2024
@bors bors merged commit f3c6608 into rust-lang:master Apr 14, 2024
12 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 14, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f3c6608): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-0.7%, -0.7%] 1
Improvements ✅
(secondary)
-2.8% [-3.6%, -2.2%] 6
All ❌✅ (primary) -0.7% [-0.7%, -0.7%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 677.553s -> 677.699s (0.02%)
Artifact size: 315.98 MiB -> 315.96 MiB (-0.00%)

@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Apr 29, 2024
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. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet