This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Description
Currently storage items have put and get. This can be fairly cumbersome when all you want to do is a minor mutation like push an item to the end of a Vec or increment by 1.
We should introduce the mutate API which basically works as:
struct X {
fn get() -> Option<Value> { ... }
fn put(v: Value) { ... }
fn kill() { ... }
fn mutate<F: FnOnce(mut v: Option<Value>)>(key: Key, f: F) {
let mut a = Self::get();
f(a);
match a {
None => Self::kill(),
Some(v) => Self::put(v),
}
}
}
It should work correctly with maps (an extra key parameter and s/put,kill/insert,remove/) and with default/required variations (s/Option/Value/).