sdleffler / qp-trie-rs

An idiomatic and fast QP-trie implementation in pure Rust.
Mozilla Public License 2.0
94 stars 24 forks source link

Features: insert_or_get_mut() #38

Open LuckyTurtleDev opened 11 months ago

LuckyTurtleDev commented 11 months ago

Hi, it would be nice if a insert_or_get_mut() would exist.

my use case: The Qp tries store bitmaps. I have a new bitmap A associated with the key 1. I would like the perform a binary and operation if a bitmap B for key 1 is already in the trie otherwise I would like to insert A. So that the value of key 1 is now A & B.

Currently I simple call .insert(A). If I get Some as return value I perform insert(A & B) again. But so I must run twice through the trie.