pub struct ReadScope(/* private fields */);Expand description
An open read scope. Hold it for the operation; dropping it leaves the scope, and dropping the outermost one drops everything the operation remembered.
Obtained from Graph::read_scope.
§Why it holds the memo rather than borrowing it
A guard that borrowed its graph would be unusable from the operations that
need it most. A mutating verb reads (a census, a subtree walk), then
stages and commits — and commit takes &mut self, which an outstanding
&self borrow forbids. Every verb in prov’s mutate is that shape, so a
borrowing guard could only be held across the read half and dropped before
the writes, which in most of them is before the expensive pass has even
started. Sharing the memo instead is what lets one scope cover a whole verb.
The lifetime tie was also a (weak) argument that a scope cannot be stashed and left open — “a memo with no end is a cache”. That argument is now discipline rather than a type: hold the guard in a local, for one operation. What has not changed is that nothing outlives it — dropping the outermost guard clears the memo, whether or not the graph is still around.