Tracking Issue for once_cell_try
· Issue #109737 · rust-lang/rust (original) (raw)
This supercedes #74465 after a portion of once_cell
was stabilized with #105587
Feature gate: #![feature(once_cell_try)]
This is a tracking issue for the *try*
methods that go with the once_cell
feature. Initially they were part of stabilization under once_cell
(#105587) but was removed due to compatibility concerns with try trait v2 (#105587 (comment)).
Public API
impl OnceCell { pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>; }
impl OnceLock { pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>; }
Steps / History
- Original implementation: Add lazy initialization primitives to std #72414
- Try trait changes: Use Try trait to make Once[Cell | Lock]::get_or_try_init generic over return type #107122
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- None yet.
cc @joboet @matklad just for reference