pub trait UnifyValue: Clone + Debug {
type Error;
// Required method
fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error>;
}
Expand description
Trait implemented for values associated with a unification key. This trait defines how to merge the values from two keys that are unioned together. This merging can be fallible. If you attempt to union two keys whose values cannot be merged, then the error is propagated up and the two keys are not unioned.
This crate provides implementations of UnifyValue
for ()
(which is infallible) and Option<T>
(where T: UnifyValue
). The
option implementation merges two sum-values using the UnifyValue
implementation of T
.
See also EqUnifyValue
, which is a convenience trait for cases
where the “merge” operation succeeds only if the two values are
equal.
Required Associated Types§
Required Methods§
sourcefn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error>
fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error>
Given two values, produce a new value that combines them. If that is not possible, produce an error.
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.