mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Silence deprecation warnings about CharacterView in stdlib
- Rename `Substring.CharacterView` to `Substring._CharacterView`, adding a deprecated typealias for the original name, like we do for `String.CharacterView`.
- Add a non-deprecated `Substring._characters` property, emulating `String.characters`.
- Explicitly deprecate the following members:
* String.withMutableCharacters<R>(_: (inout CharacterView) -> R) -> R
* String.subscript(Range<Index>) -> String.CharacterView
* Substring._CharacterView.subscript(Range<Index>) -> Substring.CharacterView
* Substring.init(_: CharacterView)
* String.init(_: Substring.CharacterView)
This commit is contained in:
@@ -140,6 +140,8 @@ extension String {
|
||||
/// argument is valid only for the duration of the closure's execution.
|
||||
/// - Returns: The return value, if any, of the `body` closure parameter.
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@available(swift, deprecated: 3.2, message:
|
||||
"Please mutate String or Substring directly")
|
||||
public mutating func withMutableCharacters<R>(
|
||||
_ body: (inout CharacterView) -> R
|
||||
) -> R {
|
||||
@@ -374,6 +376,8 @@ extension String._CharacterView {
|
||||
/// - Complexity: O(*n*) if the underlying string is bridged from
|
||||
/// Objective-C, where *n* is the length of the string; otherwise, O(1).
|
||||
@_inlineable // FIXME(sil-serialize-all)
|
||||
@available(swift, deprecated: 3.2, message:
|
||||
"Please use String or Substring directly")
|
||||
public subscript(bounds: Range<Index>) -> String.CharacterView {
|
||||
let offsetRange: Range<Int> =
|
||||
_toBaseIndex(bounds.lowerBound).encodedOffset ..<
|
||||
|
||||
Reference in New Issue
Block a user