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

core::iter::ArrayChunks does not return the remainder if None is never yielded #123333

Closed
jwong101 opened this issue Apr 1, 2024 · 1 comment · Fixed by #123406
Closed

core::iter::ArrayChunks does not return the remainder if None is never yielded #123333

jwong101 opened this issue Apr 1, 2024 · 1 comment · Fixed by #123406
Assignees
Labels
C-bug Category: This is a bug. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@jwong101
Copy link
Contributor

jwong101 commented Apr 1, 2024

I tried this code:

#![feature(iter_array_chunks)]


fn main() {
    let x = [1].into_iter().array_chunks::<2>();
    let x = x.into_remainder();
    assert!(x.is_some());
}

I expected to see this happen:
There should be a remainder as 1 will not be yielded.

Instead, this happened:

   Compiling playground v0.0.1 (/playground)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.47s
     Running `target/debug/playground`
thread 'main' panicked at src/main.rs:7:5:
assertion failed: x.is_some()

If this is intended behavior, then it should probably be documented, as the current documentation of ArrayChunks::into_remainder states that it:

Returns an iterator over the remaining elements of the original iterator that are not going to be returned by this iterator. The returned iterator will yield at most N-1 elements.

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (805813650 2024-03-31)
binary: rustc
commit-hash: 805813650248c1a2f6f271460d728d1bb852d2a7
commit-date: 2024-03-31
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2
@jwong101 jwong101 added the C-bug Category: This is a bug. label Apr 1, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 1, 2024
@jwong101 jwong101 changed the title std::iterator::ArrayChunks does not return the remainder if None is never yielded core::iter::ArrayChunks does not return the remainder if None is never yielded Apr 1, 2024
@oli-obk oli-obk added T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 3, 2024
@krtab
Copy link
Contributor

krtab commented Apr 3, 2024

@rustbot claim

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Apr 18, 2024
…cottmcm

Force exhaustion in iter::ArrayChunks::into_remainder

Closes: rust-lang#123333
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Apr 18, 2024
…cottmcm

Force exhaustion in iter::ArrayChunks::into_remainder

Closes: rust-lang#123333
@bors bors closed this as completed in 3831cbb Apr 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 19, 2024
Rollup merge of rust-lang#123406 - krtab:fix_remainder_iterchunk, r=scottmcm

Force exhaustion in iter::ArrayChunks::into_remainder

Closes: rust-lang#123333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants