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 core::iter::once_with() #57579

Merged
merged 6 commits into from Jan 15, 2019

Conversation

Projects
None yet
8 participants
@stjepang
Copy link
Contributor

stjepang commented Jan 13, 2019

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 was marked as outdated.

Copy link
Collaborator

rust-highfive commented Jan 13, 2019

r? @kennytm

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

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

rust-highfive commented Jan 13, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0464b89f:start=1547397888245712305,finish=1547397960847756176,duration=72602043871
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:59:31]     Checking compiler_builtins v0.1.4
[00:59:33]  Documenting alloc v0.0.0 (/checkout/src/liballoc)
[00:59:38]     Finished release [optimized] target(s) in 39.66s
[00:59:38]  Documenting core v0.0.0 (/checkout/src/libcore)
[00:59:57] error: `[chain]` cannot be resolved, ignoring it...
[00:59:57]     |
[00:59:57]     |
[00:59:57] 431 | /// This is commonly used to adapt a single value generator into a [`chain`] of
[00:59:57]     |
[00:59:57] note: lint level defined here
[00:59:57]    --> src/libcore/lib.rs:64:9
[00:59:57]     |
[00:59:57]     |
[00:59:57] 64  | #![deny(intra_doc_link_resolution_failure)]
[00:59:57]     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:59:57]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[00:59:57] 
[00:59:57] error: `[chain]` cannot be resolved, ignoring it...
[00:59:57]     |
[00:59:57]     |
[00:59:57] 431 | /// This is commonly used to adapt a single value generator into a [`chain`] of
[00:59:57]     |
[00:59:57]     = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
[00:59:57] 
[00:59:57] error: Could not document `core`.
[00:59:57] error: Could not document `core`.
[00:59:57] 
[00:59:57] Caused by:
[00:59:57]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustdoc --crate-name core src/libcore/lib.rs --color always --target x86_64-unknown-linux-gnu -o /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/doc --markdown-css rust.css --markdown-no-toc --index-page /checkout/src/doc/index.md -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/release/deps` (exit code: 1)
[00:59:57] 
[00:59:57] 
[00:59:57] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "rustdoc" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-Z" "unstable-options" "-p" "core" "--" "--markdown-css" "rust.css" "--markdown-no-toc" "--index-page" "/checkout/src/doc/index.md"
[00:59:57] 
[00:59:57] 
[00:59:57] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap doc
[00:59:57] Build completed unsuccessfully in 0:05:30
[00:59:57] Build completed unsuccessfully in 0:05:30
[00:59:57] Makefile:18: recipe for target 'all' failed
[00:59:57] make: *** [all] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:21181220
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sun Jan 13 17:46:07 UTC 2019
---
travis_time:end:14e1bba8:start=1547401568304317942,finish=1547401568313890284,duration=9572342
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:06993a8f
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0f911f23
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@frewsxcv frewsxcv added the T-libs label Jan 13, 2019

@frewsxcv

This comment has been minimized.

Copy link
Member

frewsxcv commented Jan 13, 2019

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Jan 13, 2019

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 was marked as outdated.

Copy link
Collaborator

rust-highfive commented Jan 13, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:1a5c3880:start=1547411138559837760,finish=1547411227197742201,duration=88637904441
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:16:40] 
[01:16:40] running 118 tests
[01:17:07] .iiiii...i.....i..i...i..i.i..i.ii..i.....i..i....i..........iiii..........i...ii...i.......ii.i.i.i 100/118
[01:17:12] ......iii.i.....ii
[01:17:12] 
[01:17:12]  finished in 31.861
[01:17:12] travis_fold:end:test_debuginfo

---
[01:29:23] travis_fold:start:test_stage1-core
travis_time:start:test_stage1-core
Testing core stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:29:24]    Compiling core v0.0.0 (/checkout/src/libcore)
[01:29:43] error[E0502]: cannot borrow `count` as immutable because it is also borrowed as mutable
[01:29:43]      |
[01:29:43]      |
[01:29:43] 1912 |     let mut it = once_with(|| {
[01:29:43]      |                            -- mutable borrow occurs here
[01:29:43] 1913 |         count += 1;
[01:29:43]      |         ----- previous borrow occurs due to use of `count` in closure
[01:29:43] 1917 |     assert_eq!(count, 0);
[01:29:43]      |                ^^^^^ immutable borrow occurs here
[01:29:43] ...
[01:29:43] 1924 | }
[01:29:43] 1924 | }
[01:29:43]      | - mutable borrow ends here
[01:29:43] 
[01:29:43] error[E0502]: cannot borrow `count` as immutable because it is also borrowed as mutable
[01:29:43]      |
[01:29:43]      |
[01:29:43] 1912 |     let mut it = once_with(|| {
[01:29:43]      |                            -- mutable borrow occurs here
[01:29:43] 1913 |         count += 1;
[01:29:43]      |         ----- previous borrow occurs due to use of `count` in closure
[01:29:43] 1919 |     assert_eq!(count, 1);
[01:29:43]      |                ^^^^^ immutable borrow occurs here
[01:29:43] ...
[01:29:43] 1924 | }
[01:29:43] 1924 | }
[01:29:43]      | - mutable borrow ends here
[01:29:43] 
[01:29:43] error[E0502]: cannot borrow `count` as immutable because it is also borrowed as mutable
[01:29:43]      |
[01:29:43]      |
[01:29:43] 1912 |     let mut it = once_with(|| {
[01:29:43]      |                            -- mutable borrow occurs here
[01:29:43] 1913 |         count += 1;
[01:29:43]      |         ----- previous borrow occurs due to use of `count` in closure
[01:29:43] 1921 |     assert_eq!(count, 1);
[01:29:43]      |                ^^^^^ immutable borrow occurs here
[01:29:43] ...
[01:29:43] 1924 | }
[01:29:43] 1924 | }
[01:29:43]      | - mutable borrow ends here
[01:29:43] 
[01:29:43] error[E0502]: cannot borrow `count` as immutable because it is also borrowed as mutable
[01:29:43]      |
[01:29:43]      |
[01:29:43] 1912 |     let mut it = once_with(|| {
[01:29:43]      |                            -- mutable borrow occurs here
[01:29:43] 1913 |         count += 1;
[01:29:43]      |         ----- previous borrow occurs due to use of `count` in closure
[01:29:43] 1923 |     assert_eq!(count, 1);
[01:29:43]      |                ^^^^^ immutable borrow occurs here
[01:29:43] 1924 | }
[01:29:43] 1924 | }
[01:29:43]      | - mutable borrow ends here
[01:29:46] error: aborting due to 4 previous errors
[01:29:46] 
[01:29:46] For more information about this error, try `rustc --explain E0502`.
[01:29:46] error: Could not compile `core`.
[01:29:46] error: Could not compile `core`.
[01:29:46] 
[01:29:46] To learn more, run the command again with --verbose.
[01:29:46] 
[01:29:46] 
[01:29:46] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "core" "--" "--quiet"
[01:29:46] 
[01:29:46] 
[01:29:46] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:29:46] Build completed unsuccessfully in 0:26:00
[01:29:46] Build completed unsuccessfully in 0:26:00
[01:29:46] make: *** [check] Error 1
[01:29:46] Makefile:48: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:09ba4826
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sun Jan 13 21:57:03 UTC 2019
---
travis_time:end:28e27d61:start=1547416625403579804,finish=1547416625462675408,duration=59095604
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:067442e8
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:01c81334
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Jan 14, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:37219e82:start=1547423227885386447,finish=1547423298566798116,duration=70681411669
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:12:44] 
[01:12:44] running 118 tests
[01:13:09] .iiiii...i.....i..i...i..i.i..i.ii..i.....i..i....i..........iiii..........i...ii...i.......ii.i.i.i 100/118
[01:13:14] ......iii.i.....ii
[01:13:14] 
[01:13:14]  finished in 29.595
[01:13:14] travis_fold:end:test_debuginfo

---
[01:24:33] 
[01:24:33] To learn more, run the command again with --verbose.
[01:24:33] 
[01:24:33] 
[01:24:33] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "core" "--" "--quiet"
[01:24:33] 
[01:24:33] 
[01:24:33] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:24:33] Build completed unsuccessfully in 0:23:39
[01:24:33] Build completed unsuccessfully in 0:23:39
[01:24:33] Makefile:48: recipe for target 'check' failed
[01:24:33] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:02bdac46
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Jan 14 01:13:01 UTC 2019
---
travis_time:end:011801a0:start=1547428383417756850,finish=1547428383487746872,duration=69990022
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:26d1a2be
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:12b19d44
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Jan 14, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:282f35c2:start=1547465115795318356,finish=1547465187629756629,duration=71834438273
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:12:24] 
[01:12:24] running 118 tests
[01:12:48] .iiiii...i.....i..i...i..i.i..i.ii..i.....i..i....i..........iiii..........i...ii...i.......ii.i.i.i 100/118
[01:12:53] ......iii.i.....ii
[01:12:53] 
[01:12:53]  finished in 29.111
[01:12:53] travis_fold:end:test_debuginfo

---
[01:25:13] running 2228 tests
[01:25:24] ......iiiii......................................................................................... 100/2228
[01:25:35] .................................................................................................... 200/2228
[01:25:48] .................................................................................................... 300/2228
[01:26:02] ......................................................i................F.F.......................... 400/2228
[01:26:26] .................................................................................................... 600/2228
[01:26:38] .................................................................................................... 700/2228
[01:26:50] .................................................................................................... 800/2228
[01:27:02] .................................................................................................... 900/2228
---
[01:29:47] ...........................................i.......................................................i 2200/2228
[01:29:51] ............................
[01:29:51] failures:
[01:29:51] 
[01:29:51] ---- iter/sources.rs - iter::sources::once_with (line 461) stdout ----
[01:29:51] error[E0658]: use of unstable library feature 'iter_once_with' (see issue #57581)
[01:29:51]   --> iter/sources.rs:473:14
[01:29:51]    |
[01:29:51] 15 | let config = iter::once_with(|| PathBuf::from(".foorc"));
[01:29:51]    |
[01:29:51]    = help: add #![feature(iter_once_with)] to the crate attributes to enable
[01:29:51] 
[01:29:51] thread 'iter/sources.rs - iter::sources::once_with (line 461)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:321:13
[01:29:51] thread 'iter/sources.rs - iter::sources::once_with (line 461)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:321:13
[01:29:51] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:29:51] 
[01:29:51] ---- iter/sources.rs - iter::sources::once_with (line 445) stdout ----
[01:29:51] error[E0658]: use of unstable library feature 'iter_once_with' (see issue #57581)
[01:29:51]  --> iter/sources.rs:449:15
[01:29:51]   |
[01:29:51] 7 | let mut one = iter::once_with(|| 1);
[01:29:51]   |
[01:29:51]   = help: add #![feature(iter_once_with)] to the crate attributes to enable
[01:29:51] 
[01:29:51] thread 'iter/sources.rs - iter::sources::once_with (line 445)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:321:13
---
[01:29:51] 
[01:29:51] error: test failed, to rerun pass '--doc'
[01:29:51] 
[01:29:51] 
[01:29:51] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "core" "--" "--quiet"
[01:29:51] 
[01:29:51] 
[01:29:51] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:29:51] Build completed unsuccessfully in 0:29:16
[01:29:51] Build completed unsuccessfully in 0:29:16
[01:29:51] Makefile:48: recipe for target 'check' failed
[01:29:51] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:2cf72b48
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Jan 14 12:56:28 UTC 2019
---
travis_time:end:2b2867c8:start=1547470590084017054,finish=1547470590088611563,duration=4594509
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:06a2e0cc
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@SimonSapin

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Jan 14, 2019

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

This comment has been minimized.

@SimonSapin

SimonSapin Jan 14, 2019

Contributor

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

@SimonSapin

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Jan 14, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 14, 2019

📌 Commit 3a1f013 has been approved by SimonSapin

Centril added a commit to Centril/rust that referenced this pull request Jan 15, 2019

Rollup merge of rust-lang#57579 - stjepang:once-with, r=SimonSapin
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.

bors added a commit that referenced this pull request Jan 15, 2019

Auto merge of #57624 - Centril:rollup, r=Centril
Rollup of 8 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)
 - #57486 (Simplify `TokenStream` some more)
 - #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

Rollup merge of rust-lang#57579 - stjepang:once-with, r=SimonSapin
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.

bors added a commit that referenced this pull request Jan 15, 2019

Auto merge of #57627 - Centril:rollup, r=Centril
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

bors added a commit that referenced this pull request Jan 15, 2019

Auto merge of #57627 - Centril:rollup, r=Centril
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

Rollup merge of rust-lang#57579 - stjepang:once-with, r=SimonSapin
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.

bors added a commit that referenced this pull request Jan 15, 2019

Auto merge of #57630 - Centril:rollup, r=Centril
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:master Jan 15, 2019

@stjepang stjepang deleted the stjepang:once-with branch Jan 15, 2019

@@ -377,6 +377,119 @@ pub fn once<T>(value: T) -> Once<T> {
Once { inner: Some(value).into_iter() }
}

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

This comment has been minimized.

@kumbayo

kumbayo Jan 15, 2019

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

This comment has been minimized.

@Centril

Centril Jan 15, 2019

Contributor

@kumbayo could you file a PR to fix this?

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