Skip to content

Commit cce957b

Browse files
Max Moiseevmoiseev
authored andcommitted
[stdlib] Removing the StringProtocol.init<T: StringProtocol>
1 parent 69f9fb5 commit cce957b

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

stdlib/public/core/String.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ public protocol StringProtocol
2121
Hashable
2222
where Iterator.Element == Character {
2323

24-
// this should be just <T : StringProtocol>
25-
init<
26-
T : LosslessStringConvertible & Sequence
27-
>(_ other: T) where T.Iterator.Element == Character
28-
2924
associatedtype UTF8Index
3025
var utf8: String.UTF8View { get }
3126
associatedtype UTF16Index
@@ -83,14 +78,6 @@ public protocol StringProtocol
8378
) rethrows -> Result
8479
}
8580

86-
extension StringProtocol {
87-
public init<
88-
T : LosslessStringConvertible & Sequence
89-
>(_ other: T) where T.Iterator.Element == Character {
90-
self.init(other.description.characters)
91-
}
92-
}
93-
9481
/// Call body with a pointer to zero-terminated sequence of
9582
/// `TargetEncoding.CodeUnit` representing the same string as `source`, when
9683
/// `source` is interpreted as being encoded with `SourceEncoding`.

stdlib/public/core/StringRangeReplaceableCollection.swift.gyb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ extension String : StringProtocol {
4141
// - init<S>(_ characters: S) where S : Sequence, S.Iterator.Element == Character
4242
// Cannot simply do init(_: String) as that would itself be ambiguous with
4343
// init?(_ description: String)
44-
public init<
45-
T : LosslessStringConvertible & Sequence
46-
>(_ other: T)
47-
where T.Iterator.Element == Character {
48-
self = other.description
44+
public init<T : StringProtocol>(_ other: T) {
45+
self.init(other.characters)
4946
}
5047

5148
/// The position of the first character in a nonempty string.

0 commit comments

Comments
 (0)