Skip to content

Tracking Issue for OnceCell::new_init #159859

Description

@Cobrand

Feature gate: #![feature(once_cell_new_init)]

This is a tracking issue for OnceCell::new_init, as discussed in the ACP: rust-lang/libs-team#817

Sister Tracking issue for OnceLock::new_init: #159860

Currently, it is impossible to create an already initialized version of OnceCell:

  • Without using the From<T> implementation for OnceCell<T>
  • In a const context

This new method aims to solve both of these issues.

Public API

impl<T> OnceCell<T> {
    pub const fn new_init(init_value: T) -> OnceCell<T>;
}

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

Unresolved Questions

  • Should the API name be new_init, or something else? Some alternatives: new_initialized, with_value, ...

Footnotes

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

Activity

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-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions