pub trait InternalExtensionValue: ExtensionValue {
// Required methods
fn as_any(&self) -> &dyn Any;
fn equals_extvalue(&self, other: &dyn InternalExtensionValue) -> bool;
fn cmp_extvalue(&self, other: &dyn InternalExtensionValue) -> Ordering;
}Expand description
Extensions provide a type implementing ExtensionValue, Eq, and Ord.
We automatically implement InternalExtensionValue for that type (with the
impl below). Internally, we use dyn InternalExtensionValue instead of
dyn ExtensionValue.
You might wonder why we don’t just have ExtensionValue: Eq + Ord and use
dyn ExtensionValue everywhere. The answer is that the Rust compiler
doesn’t let you because of
object safety.
So instead we have this workaround where we define our own equals_extvalue
method that compares not against &Self but against &dyn InternalExtensionValue,
and likewise for cmp_extvalue.
Required Methods§
Sourcefn equals_extvalue(&self, other: &dyn InternalExtensionValue) -> bool
fn equals_extvalue(&self, other: &dyn InternalExtensionValue) -> bool
this will be the basis for PartialEq on InternalExtensionValue; but
note the &dyn (normal PartialEq doesn’t have the dyn)
Sourcefn cmp_extvalue(&self, other: &dyn InternalExtensionValue) -> Ordering
fn cmp_extvalue(&self, other: &dyn InternalExtensionValue) -> Ordering
this will be the basis for Ord on InternalExtensionValue; but note
the &dyn (normal Ord doesn’t have the dyn)