Trait rusttyc::types::ContextSensitiveVariant [−][src]
pub trait ContextSensitiveVariant: Sized + Clone + Debug {
type Err: Debug;
type Context: Debug;
fn top() -> Self;
fn meet(
lhs: Partial<Self>,
rhs: Partial<Self>,
ctx: &Self::Context
) -> Result<Partial<Self>, Self::Err>;
fn arity(&self, ctx: &Self::Context) -> Arity;
fn equal(this: &Self, that: &Self, ctx: &Self::Context) -> bool;
}
Expand description
Associated Types
Result of a meet of two incompatible type, i.e., it represents a type contradiction. May contain information regarding why the meet failed. The error will be wrapped into a crate::TcErr providing contextual information.
Required methods
Attempts to meet two variants respecting their currently-determined potentially variable arity.
Refer to Variant for the responsibilities of this function.
In particular: usize::max(lhs.least_arity, rhs.least_arity) <= result.least_arity
In the successful case, the variant and arity of the partial have to match, i.e., if the Arity
is fixed with value n
, then Partial::least_arity needs to be n
as well.
Indicates whether the variant has a fixed arity. Note that this values does not have to be constant over all instances of the variant. A tuple, for example, might have a variable arity until the inferrence reaches a point where it is determined to be a pair or a triple. The pair and triple are both represented by the same type variant and have a fixed, non-specific arity. Before obtaining this information, the tuple has a variable arity and potentially a different variant.