Tracking Issue for Option::get_or_try_insert_with
Open
@lolbinarycat is already working on this.
Since Jul 8, 2025.
C-tracking-issue
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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 https://github.com/rust-lang/libs-team/issues/577
- Implementation: #143650
- Final comment period (FCP)^1
- Stabilization PR
Unresolved Questions
- None yet.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.