michaelsproul / rust_radix_trie

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

`Trie::remove()` sometimes sometime removes more than one element #11

Closed dwrensha closed 9 years ago

dwrensha commented 9 years ago
extern crate radix_trie;
use radix_trie::Trie;

fn main() {
    let mut trie = Trie::new();
    trie.insert("a", ());
    trie.insert("p", ());
    trie.remove(&"a");
    assert_eq!(trie.len(), 1); 
}
thread '<main>' panicked at 'assertion failed: `(left == right)` (left: `0`, right: `1`)',

I think this occurs whenever the root node goes from having 2 children to having only 1 child. Trie::delete_node() tries to replace the root node with its only child, but Trie::remove() ignores the DeleteAction that would make this work.

dwrensha commented 9 years ago

Yay, thanks for fixing!