tiborschneider / prefix-trie

Apache License 2.0
20 stars 4 forks source link

Add `PrefixMap::children_mut` method #12

Closed scotow closed 1 month ago

scotow commented 1 month ago

It would be nice to be able to modify children values when iterating over them. As of today, the workaround is to do this:

for (net, value) in map.children(&net).map(|(n, t)| (n, t.clone())).collect::<Vec<_>>() {
    value += 1;
    assert!(map.insert(net, value).is_some());
}
tiborschneider commented 1 month ago

Thanks for the comment. I agree that most of the iterators could (and maybe should) have a mutable variant as well. Sounds like a good use-case for macros. I will take a look at this.

tiborschneider commented 1 month ago

fixed in 8cd6bcde8614f17e50be91396553702a679e3133, published with version 0.5.0

scotow commented 1 month ago

Thanks for the quick implementation!