id-tree icon indicating copy to clipboard operation
id-tree copied to clipboard

make remove_node return data instead of node

Open spearman opened this issue 5 years ago • 2 comments

This changes remove_node to return a T value instead of a Node<T>.

spearman avatar Aug 14 '19 23:08 spearman

I do prefer this API to the existing one (as you can probably tell by how slab_tree works).

In general, I don't think users of this library should have to deal with data/constructs that don't matter to them, but the existing API forces you to deal with creating Nodes when you want to insert, and receiving Nodes when you want to remove.

With all of that said though, this is a breaking change and if we go this route I'd like to make this type of change across the whole API surface instead of just on remove_node (wherever it makes sense). I'm not saying you need to be the person to make the other changes necessarily, but you are welcome to do so if you would like.

Do you have any thoughts / opinions here?

iwburns avatar Aug 15 '19 13:08 iwburns

The way slab_tree works does seem more ergonomic, but this is the only place so far where I wasn't able to get the behavior I wanted (returning the original value without having to clone out of the node), otherwise it's been pretty usable.

spearman avatar Aug 15 '19 18:08 spearman