Skip to content

Tracking Issue for Option::get_or_try_insert_with #143648

Open
@lolbinarycat

Description

@lolbinarycat

Feature gate: #![feature(option_get_or_try_insert_with)]

This is a tracking issue for the Option::get_or_try_insert_with method

This method offers a convenient way of caching fallible operations, similar to OnceLock::get_or_try_init.

Public API

// core::option

impl Option {

use std::ops::{Residual, Try};
pub fn try_get_or_insert_with<'a, R, F>(
    &'a mut self,
    f: F,
) -> <R::Residual as Residual<&'a mut T>>::TryType
where
    F: FnOnce() -> R,
    R: Try<Output = T, Residual: Residual<&'a mut T>>;
}

Steps / History

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

Unresolved Questions

  • None yet.

Footnotes

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

Metadata

Metadata

Assignees

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