Skip to main content

Module index

Module index 

Source
Expand description

Fallible lookup, the operation the unordered field types diff through.

std::ops::Index cannot express a diff: it panics when the element is absent, and “is this element on the other side?” is the only question a membership diff asks. TryIndex is that trait with the answer made fallible, which is what lets bag and map push the lookup down into the collection instead of scanning it.

The consequence is that a field’s cost is the cost of the collection you picked: a diff over a HashSet or HashMap is O(n), and over a BTreeSet or BTreeMap it is O(n log n).

Traits§

TryIndex
A collection that can look an element up by key without panicking when it is not there.
TryIndexMut
A TryIndex whose elements can also be modified in place.