I want to point out a recent discussion bit (though the thread itself is about something else) about avoiding CoW: [ANN] CeedNumerics released (SN's ShapedArray API discussion) - #31 by Lantua.
Essentially there is a problem when the yield
ing value is not a simple element value, but a more complex variable containing self
like most Subsequence
.
In those cases modify
couldn't help avoiding CoW due to the similar problem the safe variance of first
example has.
It could be orthogonal to the modify
(as a separate accessor), somewhat related (borrow context block + modify accessor), or even as part of the future direction (move-only type?). So I think it's worth pointing out.