Skip to content

fold_first iterator consumer #106348

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

Closed
wants to merge 4 commits into from

Conversation

conradludgate
Copy link
Contributor

@conradludgate conradludgate commented Jan 1, 2023

how many iterator adapters/consumers are we going to add...

rust-lang/libs-team#157

This simple extension on fold is very similar to reduce, but on numerous occasions I have wanted to reduce but into a different type. This means I manually re-implement reduce with fold every time I need that.

This implements a fold_first (please bikeshed) which provides an init method. reduce is re-implemented as fold_first(identity, f)

Similarly, I've implemented the try/rfold variants too

@rustbot
Copy link
Collaborator

rustbot commented Jan 1, 2023

r? @Mark-Simulacrum

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

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

rustbot commented Jan 1, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@Noratrieb
Copy link
Member

You need an ACP first.

@Noratrieb Noratrieb added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 1, 2023
@rust-log-analyzer

This comment has been minimized.

@Noratrieb Noratrieb added S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 1, 2023
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
configure: rust.debug-assertions := True
configure: rust.overflow-checks := True
configure: llvm.assertions      := True
configure: dist.missing-tools   := True
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
Attempting with retry: make prepare
---
   Compiling unwind v0.0.0 (/checkout/library/unwind)
error[E0405]: cannot find trait `Residual` in this scope
   --> library/core/src/iter/traits/double_ended.rs:356:22
    |
356 |         R::Residual: Residual<Option<R::Output>>,
    |
help: consider importing this trait
    |
1   | use crate::ops::Residual;
1   | use crate::ops::Residual;
    |

error[E0412]: cannot find type `ChangeOutputType` in this scope
    |
    |
350 |     ) -> ChangeOutputType<R, Option<R::Output>>
    |
help: consider importing this type alias
    |
    |
1   | use crate::ops::ChangeOutputType;

error[E0433]: failed to resolve: use of undeclared type `FromResidual`
   --> library/core/src/iter/traits/double_ended.rs:364:38
    |
    |
364 |             ControlFlow::Break(r) => FromResidual::from_residual(r),
    |                                      ^^^^^^^^^^^^ use of undeclared type `FromResidual`
help: consider importing this trait
    |
1   | use crate::ops::FromResidual;
    |

@bors
Copy link
Collaborator

bors commented Feb 25, 2023

☔ The latest upstream changes (presumably #108421) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants