rpds icon indicating copy to clipboard operation
rpds copied to clipboard

Clarification on red-black tree node's color change

Open dotnwat opened this issue 3 months ago • 0 comments

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:

  1. If make_mut doesn't clone the node, then the color is changed in place
  2. If make_mut does 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!

dotnwat avatar Oct 09 '25 02:10 dotnwat