Open
Description
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.)
- ACP Accepted Option::try_get_or_insert_with libs-team#577
- Implementation: core: add Option::get_or_try_insert_with #143650
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- None yet.