Trait rustc_data_structures::unify::UnifyKey
source · pub trait UnifyKey: Copy + Clone + Debug + PartialEq<Self> {
type Value: UnifyValue;
// Required methods
fn index(&self) -> u32;
fn from_index(u: u32) -> Self;
fn tag() -> &'static str;
// Provided method
fn order_roots(
a: Self,
a_value: &Self::Value,
b: Self,
b_value: &Self::Value
) -> Option<(Self, Self)> { ... }
}
Expand description
This trait is implemented by any type that can serve as a type
variable. We call such variables unification keys. For example,
this trait is implemented by IntVid
, which represents integral
variables.
Each key type has an associated value type V
. For example, for
IntVid
, this is Option<IntVarValue>
, representing some
(possibly not yet known) sort of integer.
Clients are expected to provide implementations of this trait; you
can see some examples in the test
module.
Required Associated Types§
type Value: UnifyValue
Required Methods§
Provided Methods§
sourcefn order_roots(
a: Self,
a_value: &Self::Value,
b: Self,
b_value: &Self::Value
) -> Option<(Self, Self)>
fn order_roots( a: Self, a_value: &Self::Value, b: Self, b_value: &Self::Value ) -> Option<(Self, Self)>
You should return first the key that should be used as root, then the other key (that will then point to the new root).
NB. The only reason to implement this method is if you want to
control what value is returned from find()
. In general, it
is better to let the unification table determine the root,
since overriding the rank can cause execution time to increase
dramatically.