michaelsproul / rust_radix_trie

Fast generic radix trie implemented in Rust
https://docs.rs/radix_trie/
MIT License
184 stars 32 forks source link

Prevent panics when removing non-existent keys #41

Closed michaelsproul closed 5 years ago

michaelsproul commented 6 years ago

There was a bug whereby removing a key that had not been inserted into the trie would cause a panic! because its value wasn't checked in recursive_remove before calling rec_remove. The length was checked instead, but in hindsight, that's obviously insufficient.

The solution was to copy (!) more of the key-checking logic from rec_remove into the top-level recursive_remove. The logic to merge the parent with its only child is not required in the top-level, because the root node should always retain its [] key.

Closes #40

michaelsproul commented 6 years ago

If you have time to review @thomaskrause, that would be great :)

michaelsproul commented 5 years ago

Awesome, I'll merge and push a release to crates.io