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_cell_into_inner #125623

Open
1 of 3 tasks
tspiteri opened this issue May 27, 2024 · 7 comments
Open
1 of 3 tasks

Tracking Issue for lazy_cell_into_inner #125623

tspiteri opened this issue May 27, 2024 · 7 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

@tspiteri
Copy link
Contributor

tspiteri commented May 27, 2024

This superceded #109736 now that the lazy_cell feature has been stabilized.

Feature gate: #[feature(lazy_cell_into_inner)]

This is a tracking issue for LazyCell::into_inner and LazyLock::into_inner.

Public API

// core::cell (in core/src/cell/lazy.rs)

impl<T, F: FnOnce() -> T> LazyCell<T, F> {
    pub const fn into_inner(this: Self) -> Result<T, F>;
}
// std::sync (in std/sync/lazy_lock.rs)

impl<T, F: FnOnce() -> T> LazyLock<T, F> {
    pub fn into_inner(this: Self) -> Result<T, F>;
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

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

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 27, 2024
@workingjubilee
Copy link
Member

workingjubilee commented May 27, 2024

@tspiteri Would you be so kind as to make the tracking issue? (you could even just edit this one) We can edit it from there if we need to change things.

@tspiteri tspiteri changed the title doc for unstable method LazyLock::into_inner links to closed tracking issue Tracking Issue for lazy_cell_consume May 28, 2024
@workingjubilee workingjubilee added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 29, 2024
@tgross35
Copy link
Contributor

tgross35 commented Jul 10, 2024

Could this be renamed to lazy_cell_into_inner? I keep thinking this is is referencing an API that uses atomic consume operations, which was discussed for the implementation of OnceLock/LazyLock but ultimately rejected (e.g. here).

@workingjubilee
Copy link
Member

Go for it.

@tgross35
Copy link
Contributor

I was mostly asking for someone to rename the issue, but here we go #127599. Rustbot has really been spot on picking reviewers for me recently.

@workingjubilee workingjubilee changed the title Tracking Issue for lazy_cell_consume Tracking Issue for lazy_cell_into_inner Jul 11, 2024
tgross35 added a commit to tgross35/rust that referenced this issue Oct 14, 2024
Other cell `into_inner` functions are const and there shouldn't be any
problem here. Make the unstable `LazyCell::into_inner` const under the
same gate as its stability (`lazy_cell_into_inner`).

Tracking issue: rust-lang#125623
Urgau added a commit to Urgau/rust that referenced this issue Oct 16, 2024
…r, r=joboet

Mark the unstable LazyCell::into_inner const

Other cell `into_inner` functions are const and there shouldn't be any problem here. Make the unstable `LazyCell::into_inner` const under the same gate as its stability (`lazy_cell_into_inner`).

Tracking issue: rust-lang#125623
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 16, 2024
Rollup merge of rust-lang#131712 - tgross35:const-lazy_cell_into_inner, r=joboet

Mark the unstable LazyCell::into_inner const

Other cell `into_inner` functions are const and there shouldn't be any problem here. Make the unstable `LazyCell::into_inner` const under the same gate as its stability (`lazy_cell_into_inner`).

Tracking issue: rust-lang#125623
jdonszelmann pushed a commit to jdonszelmann/rust that referenced this issue Oct 17, 2024
Other cell `into_inner` functions are const and there shouldn't be any
problem here. Make the unstable `LazyCell::into_inner` const under the
same gate as its stability (`lazy_cell_into_inner`).

Tracking issue: rust-lang#125623
@tgross35
Copy link
Contributor

Could this be considered for stabilization? This serves the same purpose as into_inner methods available on other cell and sync types, and the signature is consistent with once_cell's Lazy::into_value.

The only downside I see here is that .unwrap() doesn't work since the closure doesn't implement Debug.

@rustbot label +I-libs-api-nominated

@rustbot rustbot added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Nov 29, 2024
@Amanieu
Copy link
Member

Amanieu commented Dec 3, 2024

We discussed this in the libs-api meeting. The use case for this method wasn't very clear and returning F as an error type seems awkward as it doesn't implement Debug (consider the signature of BufWriter::into_inner for comparison).

Since the initialization function is infallible, we wondered if a force_into function wouldn't be a better fit for use cases in practice.

@Amanieu Amanieu removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Dec 3, 2024
@joshtriplett
Copy link
Member

To the extent people do need the method that returns the closure, that method might make sense to call into_parts, and use a dedicated enum rather than using Result.

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

6 participants