diff --git a/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary+Partial MutableCollection.swift b/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary+Partial MutableCollection.swift index 2c07c148..6b6aed5c 100644 --- a/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary+Partial MutableCollection.swift +++ b/Sources/OrderedCollections/OrderedDictionary/OrderedDictionary+Partial MutableCollection.swift @@ -83,8 +83,7 @@ extension OrderedDictionary { // in place. The hash bucket is unchanged, so no rehash is needed. if existingIndex == index { let oldKey = _keys.update(key, at: index) - let oldValue = _values[index] - _values[index] = value + let oldValue = exchange(&_values[index], with: value) _checkInvariants() return (oldKey, oldValue) }