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.
Eh, I thought I could get away with only implementing !TransactionSafe for &Cell.
Having to account for statics is actually unfortunate. It can be worked around, but that would be too ugly for std. Lame.
qcell gets cumbersome for stuff like side-effects in chained combinators. RefCell works, but getting rid of any overhead in certain cases would be nice for gestalt purposes.