Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Tracking Issue for lazy_get #129333

Open
1 of 5 tasks
ChayimFriedman2 opened this issue Aug 20, 2024 · 3 comments
Open
1 of 5 tasks

Tracking Issue for lazy_get #129333

ChayimFriedman2 opened this issue Aug 20, 2024 · 3 comments
Labels
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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

2 participants