[stdlib] annotate uses of Range.init(_uncheckedBounds:)

This commit is contained in:
Guillaume Lessard
2025-03-05 18:52:11 -08:00
parent eed9c46116
commit dfb2e2f12e
14 changed files with 58 additions and 44 deletions

View File

@@ -218,7 +218,7 @@ extension String: RangeReplaceableCollection {
/// - Complexity: O(*n*), where *n* is the length of the string.
public mutating func insert(_ newElement: Character, at i: Index) {
let i = _guts.validateInclusiveScalarIndex(i)
let range = Range(_uncheckedBounds: (i, i))
let range = unsafe Range(_uncheckedBounds: (i, i))
_guts.replaceSubrange(range, with: newElement._str)
}
@@ -243,7 +243,7 @@ extension String: RangeReplaceableCollection {
contentsOf newElements: S, at i: Index
) where S.Element == Character {
let i = _guts.validateInclusiveScalarIndex(i)
let range = Range(_uncheckedBounds: (i, i))
let range = unsafe Range(_uncheckedBounds: (i, i))
_guts.replaceSubrange(range, with: newElements)
}