Thanks, opened [SE-0357] Typos and fixes by milseman · Pull Request #1646 · apple/swift-evolution · GitHub
StringProtocol
is.... not well designed and insufficient for this purpose alone. We'd still need the where
as you pointed out. At that point, overly constraining ourselves isn't that useful and we definitely don't want to be pushing anyone to conform to StringProtocol
.
Being able to vend a Substring
means that you're also creating a proper String
for the base
property, and doing so as a subsequence means you're not (likely) doing a copy every time. It's conceivable that we'll support some notion of (safely!) shared strings in the future with move semantics and it's conceivable that a type may vend a string-view. At that point, it's just better to use the slice (or string) as the adapter type without having another conformance to StringProtocol
.
TL;DR: StringProtocol
doesn't get us anything and we want there to be less of it in the future, not more.