mirror of
https://github.com/apple/swift-collections
synced 2026-11-28 05:04:21 +00:00
_BSubstring.UnicodeScalarView: Fix range-replacing mutations that don’t take indices
This commit is contained in:
1 file changed
+8
-5
@@ -257,14 +257,16 @@ extension _BSubstring.UnicodeScalarView: RangeReplaceableCollection {
|
||||
}
|
||||
|
||||
internal mutating func append(_ newElement: UnicodeScalar) {
|
||||
_mutateBasePreservingBounds(in: endIndex ..< endIndex) {
|
||||
$0.append(newElement)
|
||||
let i = endIndex
|
||||
_mutateBasePreservingBounds(in: i ..< i) {
|
||||
$0.insert(newElement, at: i)
|
||||
}
|
||||
}
|
||||
|
||||
internal mutating func append<S: Sequence<UnicodeScalar>>(contentsOf newElements: __owned S) {
|
||||
_mutateBasePreservingBounds(in: endIndex ..< endIndex) {
|
||||
$0.append(contentsOf: newElements)
|
||||
let i = endIndex
|
||||
_mutateBasePreservingBounds(in: i ..< i) {
|
||||
$0.insert(contentsOf: newElements, at: i)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +287,8 @@ extension _BSubstring.UnicodeScalarView: RangeReplaceableCollection {
|
||||
|
||||
@discardableResult
|
||||
internal mutating func remove(at i: Index) -> UnicodeScalar {
|
||||
_mutateBasePreservingBounds(in: i ..< i) {
|
||||
let j = self.index(after: i)
|
||||
return _mutateBasePreservingBounds(in: i ..< j) {
|
||||
$0.remove(at: i)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user