I was thinking of ways to minimize runtime state-tracking for Cell-like containers. One option uses a closure with special constraints: it must not capture another Cell object, therefore making it legal to mutably borrow Cell's interiors.
Am I missing some weird corner case that makes it unsound?
Is this too specific? Nightly Cell already has update() for Copy types, but it doesn't require a single-use trait for it to work.
This can be extended in two ways:
a. Add a marker trait InteriorMutability and implement TransactionSafe for & !InteriorMutability rather than for &Cell specifically. This allows adding transact-like apis for custom data types, but at the cost of another super-specialized feature.
b. Make it so a closure is TransactionSafe as long as it does not capture an object of the same type as current Cell instead of forbidding any interior mutability altogether. I think this is possible, but my brain kinda gave up.