shame
shame copied to clipboard
remove `Index<Key<_>>` and `IndexMut<Key<_>>` implementations of pools
Replace the Index<Key<_>> and IndexMut<Key<_>> implementations of PoolRefMut<'_, T> and PoolRef<'_, T> with fallible indexing, so that no panics can ever happen from a generation check failing. That way we can be more confident in the "no panics" guarantee we provide to users.
At the moment both PoolRefMut<'_, T> and PoolRef<'_, T> have an index implementation that checks if the Key generation matches the one of the pool, but it does so via an assertion:
assert!(key.generation == self.generation);
Replacing this with a Result::Err based check would require some other changes on the usage sites. We may also postpone this change until after a new error handling mechanism for InvalidReason::CreatedWithNoActiveEncoding is in place.