144. One ownership model, written out with exercises (2026-11-21)
- Decision.
spec/core/05-ownership.mdstates the whole model as rules R1 to R12 and wins over older text. It settles:.clone()is the copy; nomut fn(5.10); push-only generators (126); plain means "no heap part"; a read lend forbids writes, not only resizes; lent values may sit in avar, field or container that dies no later than their sources (relaxes 5.14 and 141 rule 3, sovar st = SegTree(V, op: closure over ws)works); lent structs can be built anywhere; closure captures are borrowed per call; 5.4's reuse of a callee'smutborrow by an inline closure is withdrawn;let p = mut a[i]is allowed;let row = rows[i]on a heap element is a read lend (atis alendsfn). Assignments run the right side, then the target's indices, then the write, soa[l] += inc(mut a[l])andxs[0] = xs.pop()!compile, both linted (a lint, not a ban, for legal but easy-to-misread code), reversing plan/19 red-team case 15. - Why. Ryan asked for one document from which any snippet can be judged at a glance; the older documents disagreed on these points.
- Reverse. Restore 141 rule 3 (lent values only in
lets), or hold closure captures for the closure's life.