rpds
rpds copied to clipboard
Clarification on red-black tree node's color change
Hi @orium I was reviewing the red-black tree code today and stumbled across this line:
https://github.com/orium/rpds/blob/0f2e3effbac59931b5bd8efe55fc2cd4a99fd875/src/map/red_black_tree_map/mod.rs#L598
It looks to me like this line has the following semantics:
- If
make_mutdoesn't clone the node, then the color is changed in place - If
make_mutdoes clone the node, then the color is changed on the new node but that node is then immediately discarded (the return value is ignored), and so the line is effectively a noop.
It's a case where I could see it being an oversight, or it being a clever one-liner. Hoping you can clarify the intention there. Thanks!