mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add requirement StringProtocol.SubSequence : StringProtocol
This commit is contained in:
@@ -21,7 +21,7 @@ public protocol StringProtocol
|
||||
TextOutputStream, TextOutputStreamable,
|
||||
LosslessStringConvertible, ExpressibleByStringLiteral,
|
||||
Hashable, Comparable
|
||||
where Iterator.Element == Character {
|
||||
where Iterator.Element == Character, SubSequence : StringProtocol {
|
||||
|
||||
associatedtype UTF8View : /*Bidirectional*/Collection
|
||||
where UTF8View.Element == UInt8 // Unicode.UTF8.CodeUnit
|
||||
|
||||
@@ -18,10 +18,14 @@ extension MyString : BidirectionalCollection {
|
||||
typealias Iterator = String.Iterator
|
||||
typealias Index = String.Index
|
||||
typealias IndexDistance = String.IndexDistance
|
||||
typealias SubSequence = MyString
|
||||
func makeIterator() -> Iterator { return base.makeIterator() }
|
||||
var startIndex: String.Index { return base.startIndex }
|
||||
var endIndex: String.Index { return base.startIndex }
|
||||
subscript(i: Index) -> Character { return base[i] }
|
||||
subscript(indices: Range<Index>) -> MyString {
|
||||
return MyString(base: String(self.base[indices]))
|
||||
}
|
||||
func index(after i: Index) -> Index { return base.index(after: i) }
|
||||
func index(before i: Index) -> Index { return base.index(before: i) }
|
||||
func index(_ i: Index, offsetBy n: IndexDistance) -> Index {
|
||||
|
||||
Reference in New Issue
Block a user