rust-lang / rust-lang/rust

Tracking Issue for `OnceCell/Lock::get_mut_or_init`

Open
#121,641 6 comments 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue disposition-merge proposed-final-comment-period T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Feature gate: #![feature(once_cell_get_mut)]

This is a tracking issue for

  • OnceCell::get_mut_or_init()
  • OnceCell::get_mut_or_try_init()
  • OnceLock::get_mut_or_init()
  • OnceLock::get_mut_or_try_init()
Public API
    pub fn get_mut_or_try_init<F, E>(&mut self, f: F) -> Result<&mut T, E>
    where
        F: FnOnce() -> Result<T, E> { ... }

    pub fn get_mut_or_init<F>(&mut self, f: F) -> &mut T
    where
        F: FnOnce() -> T { ... }
Steps / History
Unresolved Questions

None yet.

Footnotes

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

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 stabilization procedure in the Rust Dev Guide and review the completed implementation in rust-lang/rust#114788, along with the ACP in libs-team#294. The tracking issue is done when the final comment period is complete and a stabilization PR has been created and merged.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.