Cell::set_if_unequal() has the caveat that "this executes PartialEq::eq() with the lock held". We can do better than that:
- Acquire the lock.
- Swap the new value in.
- Release the lock.
- Compare the old value.
- If unequal, send a notification.
This is a visible behavior change because it swaps values even if unnecessary, so if downstream cares at all about differences ignored by PartialEq like pointer addresses, it could detect the difference, but that should be acceptable in nearly all cases. Still, I think the new operation should be a new method with clear documentation.
Cell::set_if_unequal()has the caveat that "this executesPartialEq::eq()with the lock held". We can do better than that:This is a visible behavior change because it swaps values even if unnecessary, so if downstream cares at all about differences ignored by
PartialEqlike pointer addresses, it could detect the difference, but that should be acceptable in nearly all cases. Still, I think the new operation should be a new method with clear documentation.