rust-lang / rust-lang/rust

Tracking Issue for `const_ref_cell`

Open
#137,844 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue S-tracking-needs-to-bake T-libs
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

Feature gate: #![feature(const_ref_cell)]

This is a tracking issue for using RefCell in a const context.

Public API
// core::cell

impl<T> RefCell<T>
    pub const fn replace(&self, t: T) -> T;
    pub const fn swap(&self, other: &Self);
}

impl<T: ?Sized> RefCell<T> {
    pub const fn borrow(&self) -> Ref<'_, T>;
    pub const fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>;
    pub const fn borrow_mut(&self) -> RefMut<'_, T>;
    pub const fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>;
    pub const fn as_ptr(&self) -> *mut T;
    pub const fn get_mut(&mut self) -> &mut T;
    pub const fn undo_leak(&mut self) -> &mut T;
    pub const unsafe fn try_borrow_unguarded(&self) -> Result<&T, BorrowError>;
}

impl<'b, T: ?Sized> Ref<'b, T> {
    pub const fn clone(orig: &Ref<'b, T>) -> Ref<'b, T>;
    pub const fn leak(orig: Ref<'b, T>) -> &'b T;
}

impl<'b, T: ?Sized> RefMut<'b, T> {
    pub const fn leak(mut orig: RefMut<'b, T>) -> &'b mut T;
}
Steps
  • Implementation: #137843
  • Final comment period (FCP)^1
  • Stabilization PR
Unresolved Questions
  • None yet.

Footnotes

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

Start by reviewing the implementation in #137843 and the stabilization process described in the linked Rust dev guide. Track the final comment period (FCP) and stabilization PR; the issue is done when both remaining checklist items are completed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.