SE-0256: Introduce {Mutable}ContiguousCollection protocol

If you have a typed pointer/buffer, you can trivially turn it into a raw pointer/buffer.

This means withUnsafeBytes could be added as a protocol extension (i.e. it wouldn't need to be a customization point on the protocol). However, I don't think this is a good idea. My personal opinion is given how trivial it is to convert from one to the other, it was a mistake to add methods to Array to do this, as it clutters the API surface without adding sufficient benefit. I would rather not perpetuate that on any new contiguously stored types in future.

This is different from Data and ContiguousBytes, which only provide untyped buffers.

You make a good point about adding the conformance to CollectionOfOne and EmptyCollection. I should have included that in this proposal.

1 Like