robclu / leapfrog

Lock-free concurrent and single-threaded hash map implementations using Leapfrog probing. Currently the highest performance concurrent HashMap in Rust for certain use cases.
Apache License 2.0
206 stars 9 forks source link

iter() yields invalid items after they are remove()d #10

Closed mosmeh closed 1 year ago

mosmeh commented 1 year ago

Code

fn main() {
    let map = leapfrog::LeapMap::new();
    assert!(map.insert(42, 123).is_none());
    assert!(map.remove(&42).is_some());
    assert!(map.remove(&42).is_none());
    assert!(map.get(&42).is_none());
    for mut x in map.iter() {
        dbg!(x.key_value());
    }
}

Expected output

Nothing or None

Actual output

[src/main.rs:8] x.key_value() = Some(
    (
        42,
        2147483646,
    ),
)