mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Making one of Substring initializers public
This commit is contained in:
@@ -174,16 +174,16 @@ extension String : RangeReplaceableCollection, BidirectionalCollection {
|
||||
///
|
||||
/// - Complexity: O(*n*) if the underlying string is bridged from
|
||||
/// Objective-C, where *n* is the length of the string; otherwise, O(1).
|
||||
public subscript(bounds: Range<Index>) -> String {
|
||||
return String(characters[bounds])
|
||||
public subscript(bounds: Range<Index>) -> Substring {
|
||||
return Substring(_base: String(self._core), bounds)
|
||||
}
|
||||
|
||||
/// Accesses the text in the given range.
|
||||
///
|
||||
/// - Complexity: O(*n*) if the underlying string is bridged from
|
||||
/// Objective-C, where *n* is the length of the string; otherwise, O(1).
|
||||
public subscript(bounds: ClosedRange<Index>) -> String {
|
||||
return String(characters[bounds])
|
||||
public subscript(bounds: ClosedRange<Index>) -> Substring {
|
||||
return Substring(_base: String(self._core), bounds)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,4 +437,3 @@ extension String {
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user