I very briefly mentioned this in the pitch thread here: `Borrow` and `Inout` types for safe, first-class references - #24 by Alejandro
Subscripts are weird and can only return a single type. For things like Array, you could theoretically have a single subscript return both a Borrow<Element> and Inout<Element> but like I mentioned in the linked post, you create an ambiguity problem:
struct Array<Element: ~Copyable>: ~Copyable {
subscript(i: Int) -> Borrow<Element> {
get { ... }
}
subscript(I: Int) -> Inout<Element> {
mutating get { ... }
}
}
let a = Array<Atomic<Int>>(...)
let b = a[0] // error: ambiguous use of subscript what type is 'B'?
While the borrow/mutate accessors don’t make it completely obvious from their return type that what’s being returned isn’t an Element, but rather technically Borrow<Element/Inout<Element>, it does resolve this ambiguity issue that Swift has.
This is fair, should the mutate accessor be called inout? Is that confusing? Mutate<T>?
I think lining up with the Span names would be hard unless you meant X and MutableX. Ref and MutableRef? SpanOfOne/MutableSpanOfOne?