I would like to overload []= instead if possible, i.e. fn set(&mut self, index: K, value: V) { ... }
The application here is: I want to log all "changes" to a data structure. Thus, I want a set instead of IndexMut (unless there is some way to do this with IndexMut I am unaware of).
This doesn't have exist yet, although there have been proposals where it was called IndexAssign iirc.
Perhaps you'd be better off just using methods rather than Index and assignments, then you can put whatever code you want, at the cost of it being slightly less convenient to use
IndexMut results in a mutable place expression that you can move into or take a &mut to, so there's no way to do it with that. More generally, if you can get a &mut of the field (or of any parent or ownership of any parent), it can be replaced by e.g. moves or other "primitive" operations.
If it's always full assignment you're dealing with (e.g. some opaque type with no mutating methods), maybe you could do something with Drop. Though someone on the other side could mem::replace and hold on to or leak the original. Some sort of Cell or Option wrapper is another possibility.