Currently, the only way to retrieve an input in inc-complete is to get the result of its computation:
fn main() {
let mut db = Db::<MyStorage>::default();
db.update_input(MyInput(3), 6);
let input = MyInput(3).get(db);
assert_eq!(input, 6);
}
However, this will panic if the input was never set:
#[test]
#[should_panic]
fn no_such_input() {
let mut db = Db::<MyStorage>::default();
let _ = MyInput(3).get(db);
}
It would be convenient if there was a way to query whether an input exists:
#[test]
fn no_such_input2() {
let mut db = Db::<MyStorage>::default();
let input = MyInput(3).try_get(db);
assert_eq!(input, None);
}
Additionally, there is no way to remove existing inputs currently. This can lead to unnecessary bloat over time, particularly when reading from pre-existing serialized dbs. A way to remove inputs would be helpful:
#[test]
fn remove_input() {
let mut db = Db::<MyStorage>::default();
let input = MyInput(3);
assert_eq!(input.try_get(db), None);
input.set(db, 6);
assert_eq!(input.try_get(db), Some(6));
input.remove(db);
assert_eq!(input.try_get(db), None);
}
Currently, the only way to retrieve an input in inc-complete is to get the result of its computation:
However, this will panic if the input was never set:
It would be convenient if there was a way to query whether an input exists:
Additionally, there is no way to remove existing inputs currently. This can lead to unnecessary bloat over time, particularly when reading from pre-existing serialized dbs. A way to remove inputs would be helpful: