Skip to content

Tracking Issue for lazy_get #129333

Closed

Description

@ChayimFriedman2

Feature gate: #![feature(lazy_get)]

This is a tracking issue for LazyCell/Lock::get[_mut](), allowing you to extract a reference from a Lazy only if it is initialized, approved in ACP rust-lang/libs-team#429.

Public API

impl<T, F> core::cell::LazyCell<T, F> {
    pub fn get(this: &Self) -> Option<&T>;
    pub fn get_mut(this: &mut Self) -> Option<&mut T>;
    pub fn force_mut(this: &mut Self) -> &mut T;
}
impl<T, F> std::sync::LazyLock<T, F> {
    pub fn get(this: &Self) -> Option<&T>;
    pub fn get_mut(this: &mut Self) -> Option<&mut T>;
    pub fn force_mut(this: &mut Self) -> &mut T;
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

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

Activity

  1. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    T-libs-api[DEPRECATED; DO NOT USE]
    on Aug 20, 2024
  2. added 2 commits that reference this issue on Sep 18, 2024
  3. added a commit that references this issue on Sep 19, 2024
  4. jalil-salame commented on Nov 29, 2024

    @jalil-salame
    Contributor

    The docs for LazyLock::get[_mut] are backwards:

    LazyLock::get:

    Returns a mutable reference to the value if initialized, or None if not.

    LazyLock::get_mut:

    Returns a reference to the value if initialized, or None if not.

    The examples are right through.

  5. ChayimFriedman2 commented on Nov 29, 2024

    @ChayimFriedman2
    ContributorAuthor

    @jalil-salame Why is that backwards? That seems correct to me.

  6. jalil-salame commented on Nov 29, 2024

    @jalil-salame
    Contributor

    @jalil-salame Why is that backwards? That seems correct to me.

    Get should get a reference not a mutable reference

    Get mut should get a mutable reference not a reference

  7. added 3 commits that reference this issue on Dec 18, 2024
  8. added a commit that references this issue on Dec 18, 2024
  9. kornelski commented on Mar 8, 2025

    @kornelski
    Contributor

    get/get_mut have been fixed. Can this be stabilized now?

  10. added a commit that references this issue on Mar 11, 2025
  11. Amanieu commented on Apr 29, 2025

    @Amanieu
    Member

    FCP to stabilize get. get_mut and force_mut.

    @rfcbot merge

  12. 33 remaining items

  13. added a commit that references this issue on Dec 24, 2025
  14. added 2 commits that reference this issue on Dec 24, 2025
  15. added a commit that references this issue on Dec 24, 2025
  16. added this to the 1.94.0 milestone on Jan 8, 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 RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions