lazy-init
lazy-init copied to clipboard
Provide get_or_create variant that returns a Result
It is somewhat unwieldy to pass a closure that can fail to get_or_create. It would be nice to have a try_get_or_create (or something like that) method on Lazy<T>. The method would take a FnOnce() -> Result<T, E> and return a Result<T, E>. The result is Ok if the transformation has been done or succeeds, and Err if the transformation function returns an Err.