jfecher / jfecher/inc-complete

Add ability to try to get an input and remove an input

Open
#6 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
17
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Currently, the only way to retrieve an input in inc-complete is to get the result of its computation:
```rs
fn main() {
let mut db = Db::::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:
```rs
#[test]
#[should_panic]
fn no_such_input() {
let mut db = Db::::default();
let _ = MyInput(3).get(db);
}
```
It would be convenient if there was a way to query whether an input exists:
```rs
#[test]
fn no_such_input2() {
let mut db = Db::::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:
```rs
#[test]
fn remove_input() {
let mut db = Db::::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);
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.