pub trait Commonality<V> {
// Required methods
fn common() -> V;
fn is_common(value: &V) -> bool;
}Expand description
Defines a notion of “common” vs. “uncommon” values for the type V, used to determine which
entries are stored in a TotalHashMap or TotalBTreeMap.
There could be multiple definitions of commonality for the same type:
- The basic implementation, DefaultCommonality, is based on the Default trait.
- EmptyCommonality is specialized for collection types.
- ZeroCommonality is based on the num_traits::Zero trait.
Required Methods§
Sourcefn common() -> V
fn common() -> V
The common value of type V.
Important: The implementations of PartialEq, Eq, PartialOrd, Ord, and
Hash for TotalHashMap and TotalBTreeMap treat all common values as
though they were equal to each other,, even if they aren’t really. For example, if you
defined a Commonality<f64> implementation where common() returned f64::NAN, maps based
on this commonality could still be equal to each other, despite the fact that f64::NAN is
not equal to itself.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.