leapfrog icon indicating copy to clipboard operation
leapfrog copied to clipboard

Fix - Value is not inserted with try_insert after removing it with remove

Open incapdns opened this issue 8 months ago • 0 comments

Value is not inserted with try_insert after removing it with remove.

The problem:

map.insert(1, 1);
map.remove(&1);
map.try_insert(1, 2);
let value = map.get(&1);

In this example, value returns None, when it should return 2

How to fix:

Replace:

if must_update

To:

if must_update || old_value.is_null()

Filename: leapmap.rs

Thanks.

incapdns avatar May 26 '25 07:05 incapdns