I will argue that Stacked Borrows can be viewed as an approximation of a
special kind of re-entrant (reader-writer) lock, where the calls to lock
and
unlock
are hidden, and Stacked Borrows attempts to infer
where they happen. The locking intuition seems like it might be useful for several reasons:
- It directly expresses "aliasing XOR mutability" by the fact that at most one user can hold the write lock at any moment, and any number of users can hold the read lock.