INNER CODE UNIT · Rust
add_increments_id
lunatic-solutions/lunatic · crates/hash-map-id/src/lib.rs:121
fn add_increments_id() {
let mut hash: HashMapId<i32> = HashMapId::new();
let id1 = hash.add(10);
let id2 = hash.add(20);
assert_eq!(id2, id1 + 1);
}
#[test]
#[should_panic]
fn add_panics_on_integer_overflow() {
let mut hash: HashMapId<i32> = HashMapId::new();
let item = 10;
hash.id_seed = std::u64::MAX;
hash.add(item);
}
// remove