Making one of Substring initializers public

This commit is contained in:
Max Moiseev
2017-02-22 17:10:54 -08:00
parent 7e8f8681bf
commit 79f4c9c80e
2 changed files with 11 additions and 11 deletions

View File

@@ -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()
}
}