This is about the 3 secret requirements for Sequence: _copyContents(initializing:), _copyToContiguousArray(), and _customContainsEquatableElement(_:). The third method is called by Sequence.contains(_:). But my searching skills on the Standard Library directory couldn't find clients that call either _copyToContiguousArray() or _copyContents(initializing:). Why do they exist if nothing calls them?
The canonical use of _copyToContiguousArray() is by ContiguousArray.init(some Sequence<Element>).
And for _copyContents(initializing:), it is UnsafeMutableBufferPointer.initialize(from: some Sequence<Element>)
These "secret" methods are really just implementation details for public, documented APIs - using dynamic dispatch to ask the parameter <S: Sequence> types in each of these functions how best to copy their contents to a contiguous destination.
You can basically call them directly under either of the above names.
1 Like