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

Unresolved Questions

cc @joboet @matklad just for reference

Footnotes

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