FnStore
FnStore is a abstraction around the HashMap, like TypeMap. But uses closure's type(each closure's type is unique in Rust) as key and stores produced value. Allowing to be used like effective low cost dependency injection container.
Usage
use LocalFnStore;
let mut store = new;
// get or compute(and insert) value using given closure. The closure depends on value of `one` function to compute its output.
let a = *store.get;
dbg!;
// b is *not* a because each closure's type is unique
let b = *store.get;
dbg!;
// get or compute(and insert) value using give function. But will not compute since it is computed already when producing a.
let c = *store.get;
dbg!;
will output
License
MIT