Going over the stdlib looking for places to adopt @_borrowed
(strawman spelling; see Add a @_borrowed attribute to force the use of an opaque read accessor by rjmccall · Pull Request #20403 · apple/swift · GitHub or the associated forum thread), there's not much.
At least arguably required for move-only types:
-
Collection.subscript(Index)
and its refinement onMutableCollection
-
_SequenceWrapper._base
(unless this should go the opposite direction and become aconsuming
method)
The following are possible minor optimizations:
-
Error._domain
, which will almost exclusively return a constant value — but usingread
in that case might not actually be an optimization over doing a no-op retain/release -
RawRepresentable.rawValue
, which I think will usually return a constant value, and which may need to be borrowed for move-only correctness -
_AnyHashableBox._canonicalBox
(not sure about this one at all) -
Encoder.codingPath
andKeyedEncodingContainerProtocol.codingPath
-
LazySequenceProtocol.elements
andLazyCollectionProtocol.elements