Currently HashMap::compute requires an FnMut and has no way of persisting state. For example, inserting a V requires cloning if the operation fails and is retried. Internally we memoize all inserts to avoid this, but that's a hack that shouldn't be expose to users. Instead we might want to provide an on_failure(Operation<V>) hook to allow state to be reset. I don't want the API to become convoluted, so maybe just guaranteeing that inserts are memoized is simpler?
Currently
HashMap::compute
requires anFnMut
and has no way of persisting state. For example, inserting aV
requires cloning if the operation fails and is retried. Internally we memoize all inserts to avoid this, but that's a hack that shouldn't be expose to users. Instead we might want to provide anon_failure(Operation<V>)
hook to allow state to be reset. I don't want the API to become convoluted, so maybe just guaranteeing that inserts are memoized is simpler?