rust-lang / rust-lang/rust

Tracking Issue for `borrowed_buf_init`

Open
#160,476 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue S-tracking-unimplemented T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Feature gate: #![feature(borrowed_buf_init)]

This is a tracking issue for borrowed_buf_init

Public API
impl<'data, T> BorrowedBuf<'data, T> {
    pub fn is_init(&self) -> bool;
}

impl<'data, T: Copy> BorrowedBuf<'data, T> {
    pub unsafe fn set_init(&mut self) -> &mut Self;
}

impl<'a, T: Copy> BorrowedCursor<'a, T> {
    pub fn is_init(&self) -> bool;
    pub unsafe fn set_init(&mut self);
    pub fn advance_checked(&mut self, n: usize) -> &mut Self;
}

impl<'a> BorrowedCursor<'a, u8> {
    pub fn ensure_init(&mut self) -> &mut [u8];
}
Steps / History
Unresolved Questions
  • Can the bounds for ensure_init be weakened to T: Default? Or should we have API more similar to [T: Clone]::fill(&mut self, value: T) / [T]::fill_with<F: FnMut() -> T>(&mut self, f: F)?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the listed BorrowedBuf and BorrowedCursor API and issue #160432 first, then review the feature-lifecycle stabilization guidance linked in the tracking issue. Done means resolving the ensure_init bounds question, completing the final comment period, and producing the stabilization PR.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.