Trait select_indices::OneToOne
source · [−]pub unsafe trait OneToOne<Idx>: IndexMut<Idx> { }
Expand description
This trait makes a number of guarantees to make sure that multiple mutable index operations do not break XOR mutability or cause undefined behavior.
Safety
By declaring this trait for an IndexMut
type, you
are asserting the following guarantees for your type:
- For every valid index, there is only one output.
- Invalid indices should panic and not return multiple references to one object.
- When mutably indexed, the type never reads any other
indexable objects (
HashMap
s are notOneToOne
because of this). - When mutably indexed, the type does not mutate itself. It should only return a mutable index to an object held by the type.