in Sources/_CollectionsTestSupport/MinimalTypes/_CollectionState.swift [199:215]
func replace(oldCount: Int, at offset: Int, with newCount: Int) {
precondition(oldCount >= 0 && offset >= 0 && newCount >= 0)
precondition(offset + oldCount <= self.count)
guard oldCount > 0 || newCount > 0 else { return }
switch strategy {
case .allIndices:
self.count += newCount - oldCount
case .afterChange:
let rest = offset ..< self.count
self.indexValidity.replaceSubrange(
rest,
with: repeatElement(id, count: rest.count + newCount - oldCount))
self.endIndexValidity = self.id
self.count += newCount - oldCount
assert(indexValidity.count == self.count)
}
}