Skip to content

Add core::iter::once_with() - #57579

Merged
bors merged 6 commits into
masterfrom
unknown repository
Jan 15, 2019
Merged

Add core::iter::once_with()#57579
bors merged 6 commits into
masterfrom
unknown repository

Conversation

@ghost

@ghostghost commented Jan 13, 2019

Copy link
Copy Markdown

Functions iter::once() and iter::repeat() construct iterators from values. The latter has the lazy variant iter::repeat_with(), but the former doesn't. This PR therefore adds iter::once_with().

Another way to think of iter::once_with() is that it's a function that converts FnOnce() -> T into Iterator<Item = T>.

If this seems like a reasonable addition, I'll open a tracking issue and update the #[feature(...)] attributes.

@rust-highfive

This comment has been minimized.

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 13, 2019
@rust-highfive

This comment has been minimized.

@frewsxcvfrewsxcv added the T-libs-api [DEPRECATED; DO NOT USE] label Jan 13, 2019
@frewsxcv

Copy link
Copy Markdown
Contributor

cc @rust-lang/libs

@Centril

Copy link
Copy Markdown
Contributor

r? @SimonSapin

I once promised @eddyb to make a PR for this but the playground ate my work... :(
Thank you for writing this up!

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@SimonSapin

Copy link
Copy Markdown
Contributor

r=me, but the doc-comment still needs #![feature(iter_once_with)]

/// over each file of the `.foo` directory, but also a configuration file,
/// `.foorc`:
///
/// ```no_run

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I’d guess here too? IIRC no_run doc-tests are still compiled.

@SimonSapin

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jan 14, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 3a1f013 has been approved by SimonSapin

@borsbors 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 Jan 14, 2019
Centril added a commit to Centril/rust that referenced this pull request Jan 15, 2019
Add core::iter::once_with()
Functions `iter::once()` and `iter::repeat()` construct iterators from values. The latter has the lazy variant `iter::repeat_with()`, but the former doesn't. This PR therefore adds `iter::once_with()`.
Another way to think of `iter::once_with()` is that it's a function that converts `FnOnce() -> T` into `Iterator<Item = T>`.
If this seems like a reasonable addition, I'll open a tracking issue and update the `#[feature(...)]` attributes.
@CentrilCentril mentioned this pull request Jan 15, 2019
Centril added a commit to Centril/rust that referenced this pull request Jan 15, 2019
Add core::iter::once_with()
Functions `iter::once()` and `iter::repeat()` construct iterators from values. The latter has the lazy variant `iter::repeat_with()`, but the former doesn't. This PR therefore adds `iter::once_with()`.
Another way to think of `iter::once_with()` is that it's a function that converts `FnOnce() -> T` into `Iterator<Item = T>`.
If this seems like a reasonable addition, I'll open a tracking issue and update the `#[feature(...)]` attributes.
@CentrilCentril mentioned this pull request Jan 15, 2019
bors added a commit that referenced this pull request Jan 15, 2019
Rollup of 7 pull requests
Successful merges:
- #57253 (Make privacy checking, intrinsic checking and liveness checking incremental)
- #57352 (forbid manually impl'ing one of an object type's marker traits)
- #57537 (Small perf improvement for fmt)
- #57579 (Add core::iter::once_with())
- #57587 (Add 'rustc-env:RUST_BACKTRACE=0' to const-pat-ice test)
- #57608 (Simplify 'product' factorial example)
- #57614 ([rustdoc] Fix crates filtering box not being filled)
Failed merges:
r? @ghost
Centril added a commit to Centril/rust that referenced this pull request Jan 15, 2019
Add core::iter::once_with()
Functions `iter::once()` and `iter::repeat()` construct iterators from values. The latter has the lazy variant `iter::repeat_with()`, but the former doesn't. This PR therefore adds `iter::once_with()`.
Another way to think of `iter::once_with()` is that it's a function that converts `FnOnce() -> T` into `Iterator<Item = T>`.
If this seems like a reasonable addition, I'll open a tracking issue and update the `#[feature(...)]` attributes.
@CentrilCentril mentioned this pull request Jan 15, 2019
bors added a commit that referenced this pull request Jan 15, 2019
Rollup of 8 pull requests
Successful merges:
- #56044 (Drop partially bound function parameters in the expected order)
- #57352 (forbid manually impl'ing one of an object type's marker traits)
- #57456 (RawVec doesn't always abort on allocation errors)
- #57467 (Implement `check_attribute` to forbid `#[allow_internal_unsafe]`)
- #57579 (Add core::iter::once_with())
- #57587 (Add 'rustc-env:RUST_BACKTRACE=0' to const-pat-ice test)
- #57608 (Simplify 'product' factorial example)
- #57614 ([rustdoc] Fix crates filtering box not being filled)
Failed merges:
r? @ghost
@bors
bors merged commit 3a1f013 into rust-lang:masterJan 15, 2019
@ghost
ghost deleted the once-with branch January 15, 2019 16:51

/// An iterator that repeats elements of type `A` endlessly by
/// applying the provided closure `F: FnMut() -> A`.
///

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It seems like his comment was copy pasted from RepeatWith.
It talks about endless repeating and FnMut().

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kumbayo could you file a PR to fix this?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libs-api[DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@rust-highfive@frewsxcv@Centril@SimonSapin@bors@kumbayo@kennytm