Skip to main content

Commonality

Trait Commonality 

Source
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:

Required Methods§

Source

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.

Source

fn is_common(value: &V) -> bool

Returns true if value is the common value of type V. Self::is_common(Self::common()) must be true.

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.

Implementors§