Skip to content

Tracking Issue for lazy_get #129333

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
2 of 5 tasks
ChayimFriedman2 opened this issue Aug 20, 2024 · 6 comments
Open
2 of 5 tasks

Tracking Issue for lazy_get #129333

ChayimFriedman2 opened this issue Aug 20, 2024 · 6 comments
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@ChayimFriedman2
Copy link
Contributor

ChayimFriedman2 commented Aug 20, 2024

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

@ChayimFriedman2 ChayimFriedman2 added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Aug 20, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 18, 2024
…ake-2, r=Amanieu

Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut`

Tracking issue for `lazy_get`: rust-lang#129333
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 18, 2024
…ake-2, r=Amanieu

Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut`

Tracking issue for `lazy_get`: rust-lang#129333
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 19, 2024
Rollup merge of rust-lang#130476 - workingjubilee:more-lazy-methods-take-2, r=Amanieu

Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut`

Tracking issue for `lazy_get`: rust-lang#129333
@jalil-salame
Copy link
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.

@ChayimFriedman2
Copy link
Contributor Author

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

@jalil-salame
Copy link
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

jieyouxu added a commit to jieyouxu/rust that referenced this issue Dec 18, 2024
…=tgross35

fix(LazyCell): documentation of get[_mut] was wrong

- `LazyCell::get`: said it was returning a **mutable** reference.
- `LazyCell::get_mut`: said it was returning a reference (the mutable was missing).

Related to rust-lang#129333 (`lazy_get`). `LazyLock`'s documentation was correct.
jieyouxu added a commit to jieyouxu/rust that referenced this issue Dec 18, 2024
…=tgross35

fix(LazyCell): documentation of get[_mut] was wrong

- `LazyCell::get`: said it was returning a **mutable** reference.
- `LazyCell::get_mut`: said it was returning a reference (the mutable was missing).

Related to rust-lang#129333 (`lazy_get`). `LazyLock`'s documentation was correct.
jieyouxu added a commit to jieyouxu/rust that referenced this issue Dec 18, 2024
…=tgross35

fix(LazyCell): documentation of get[_mut] was wrong

- `LazyCell::get`: said it was returning a **mutable** reference.
- `LazyCell::get_mut`: said it was returning a reference (the mutable was missing).

Related to rust-lang#129333 (`lazy_get`). `LazyLock`'s documentation was correct.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 18, 2024
Rollup merge of rust-lang#134452 - jalil-salame:fix-lazy-cell-docs, r=tgross35

fix(LazyCell): documentation of get[_mut] was wrong

- `LazyCell::get`: said it was returning a **mutable** reference.
- `LazyCell::get_mut`: said it was returning a reference (the mutable was missing).

Related to rust-lang#129333 (`lazy_get`). `LazyLock`'s documentation was correct.
@kornelski
Copy link
Contributor

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

github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this issue Mar 11, 2025
…=tgross35

fix(LazyCell): documentation of get[_mut] was wrong

- `LazyCell::get`: said it was returning a **mutable** reference.
- `LazyCell::get_mut`: said it was returning a reference (the mutable was missing).

Related to rust-lang#129333 (`lazy_get`). `LazyLock`'s documentation was correct.
@Amanieu
Copy link
Member

Amanieu commented Apr 29, 2025

FCP to stabilize get. get_mut and force_mut.

@rfcbot merge

@rfcbot
Copy link
Collaborator

rfcbot commented Apr 29, 2025

Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Apr 29, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants