File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -51,9 +51,18 @@ extension String: RangeReplaceableCollection {
51
51
///
52
52
/// - Parameter other: A string instance or another sequence of
53
53
/// characters.
54
- @inlinable // FIXME(sil-serialize-all)
54
+ @_specialize ( where S == String)
55
+ @_specialize ( where S == Substring)
55
56
public init < S : Sequence & LosslessStringConvertible > ( _ other: S )
56
57
where S. Element == Character {
58
+ if let str = other as? String {
59
+ self . init ( str)
60
+ return
61
+ }
62
+ if let subStr = other as? Substring {
63
+ self . init ( subStr)
64
+ return
65
+ }
57
66
self = other. description
58
67
}
59
68
@@ -72,9 +81,19 @@ extension String: RangeReplaceableCollection {
72
81
///
73
82
/// - Parameter characters: A string instance or another sequence of
74
83
/// characters.
75
- @inlinable // specialize
84
+ @_specialize ( where S == String)
85
+ @_specialize ( where S == Substring)
86
+ @_specialize ( where S == Array< Character> )
76
87
public init < S : Sequence > ( _ characters: S )
77
88
where S. Iterator. Element == Character {
89
+ if let str = characters as? String {
90
+ self . init ( str)
91
+ return
92
+ }
93
+ if let subStr = characters as? Substring {
94
+ self . init ( subStr)
95
+ return
96
+ }
78
97
self = " "
79
98
self . append ( contentsOf: characters)
80
99
}
Original file line number Diff line number Diff line change @@ -717,8 +717,19 @@ extension Substring.UnicodeScalarView : RangeReplaceableCollection {
717
717
}
718
718
719
719
extension Substring : RangeReplaceableCollection {
720
+ @_specialize ( where S == String)
721
+ @_specialize ( where S == Substring)
722
+ @_specialize ( where S == Array< Character> )
720
723
public init < S : Sequence > ( _ elements: S )
721
724
where S. Element == Character {
725
+ if let str = elements as? String {
726
+ self . init ( str)
727
+ return
728
+ }
729
+ if let subStr = elements as? Substring {
730
+ self . init ( subStr)
731
+ return
732
+ }
722
733
self = String ( elements) [ ... ]
723
734
}
724
735
You can’t perform that action at this time.
0 commit comments