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:

  1. For every valid index, there is only one output.
  2. Invalid indices should panic and not return multiple references to one object.
  3. When mutably indexed, the type never reads any other indexable objects (HashMaps are not OneToOne because of this).
  4. When mutably indexed, the type does not mutate itself. It should only return a mutable index to an object held by the type.

Implementations on Foreign Types

Implementors