News for hackers. Stuff that matters.
Re:Mental models around Ok-Wrapping by jlokier on Friday April 10, 2020 @11:35AM (#22834080)
> I still haven’t figured how to map things like cached_results: HashMap<u32, Result<String, Error>> into the fallible function model. In this case, there’s no function that could be fallible.

Oh you can definitely make a generically cached version of a fallible function, by either:

- Re-throwing the same exception at future lookups, or a clone if preferred (requires storing the exception)

- Treating the exception case as an uncacheable value (always logically consistent with caches that allow items to disappear at any time)

There are no comments on this comment yet.