Skip to content

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

Description

@jwong101

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

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 1, 2024
  2. 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[/+] on Apr 1, 2024
  3. added
    T-libsRelevant to the library team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 3, 2024
  4. krtab commented on Apr 3, 2024

    @krtab
    Contributor

    @rustbot claim

  5. added a commit that references this issue on Apr 18, 2024
    c8d529d
  6. added 2 commits that reference this issue on Apr 18, 2024
    1298318
    3831cbb
  7. added a commit that references this issue on Apr 19, 2024
    0842e0d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions