Skip to content

Tracking Issue for read_array #148848

Open
Open

Description

@joshtriplett

Feature gate: #![feature(read_array)]

This is a tracking issue for the read_array feature, which provides the Read::read_array method.

Public API

// std::io

impl Read {
    fn read_array<N: usize>(&mut self) -> Result<[u8; N]>
    where
        Self: Sized,
    {
        /* ... */
    }
}

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩

Activity

  1. added
    T-libs-api[DEPRECATED; DO NOT USE]
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Nov 11, 2025
  2. added 7 commits that reference this issue on Nov 13, 2025
  3. added a commit that references this issue on Nov 14, 2025
  4. lyphyser commented on Nov 26, 2025

    @lyphyser

    I think this should return an ArrayVec equivalent (in which case the caller would chain a try_into() to get a plain array if they want).

    Currently, it throws away data if there is some data available but not enough to fill the array, which is not a good interface.

    It would be even more general to take an ArrayVec by &mut reference, and even more general some trait that can take both a Vec and an ArrayVec.

  5. Amanieu commented on Nov 27, 2025

    @Amanieu
    Member

    This is intended to be used like read_exact where you expect a certain number of bytes and any early EOF should be treated as an error (and the corresponding bytes simply dropped). If you need to handle early EOF then you should be using read instead of this.

  6. added 2 commits that reference this issue on Nov 30, 2025
  7. Amanieu commented on Dec 9, 2025

    @Amanieu
    Member

    This should only be stabilized as a final method as per rust-lang/rfcs#3678. This will allow read_array to work on dyn Read types.

  8. thaliaarchi commented on Jun 26, 2026

    @thaliaarchi
    Contributor

    @Amanieu Why does whether read_array can be overridden have any bearing on it working on dyn Read types?

    Besides that, I don't think it absolutely needs to be final. For example, someone may want to eliminate the potential panic if they can guarantee correctness of read_buf_exact.

  9. Amanieu commented on Jun 26, 2026

    @Amanieu
    Member

    In order to keep Read dyn-compatible we would need to add where Self: Sized bounds to the method so it doesn't get included in the vtable. However it then becomes impossible to use this method with a dyn Read. If we want this method to be available on dyn Read then it must be a final fn, and that's not something we can do in the future in a backwards-compatible manner.

  10. added
    T-libsRelevant to the library team, which will review and decide on the PR/issue.
    and removed
    T-libs-api[DEPRECATED; DO NOT USE]
    on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.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