pub struct TypeSet {
pub nodes: Vec<TNode>,
pub subst: Vec<(usize, TypeRef)>,
pub next_var: usize,
}Fields§
§nodes: Vec<TNode>§subst: Vec<(usize, TypeRef)>§next_var: usizeImplementations§
Source§impl TypeSet
impl TypeSet
pub fn add_tp(&mut self, tp: &Type) -> RawTypeRef
Sourcepub fn empty() -> TypeSet
pub fn empty() -> TypeSet
This is the usual way of creating a new Context. The context will be append-only meaning you can roll it back to a point by truncating
pub fn save_state(&self) -> (usize, usize)
pub fn load_state(&mut self, state: (usize, usize))
Sourcepub fn might_unify(&self, t1: &RawTypeRef, t2: &TypeRef) -> bool
pub fn might_unify(&self, t1: &RawTypeRef, t2: &TypeRef) -> bool
a very quick non-allocating check that returns false if it’s obvious that these types won’t unify. This works even when a type hasnt been instantiated() to have new type variables. First this checks if t1 and t2 have the same constructors and if theres an obvious mismatch there it gives up. Then it goes and looks up the types in the ctx in case they were typevars, and then again checks if they have th same constructor. It uses apply_immut() to avoid mutating the context for this lookup. Note the apply_immut version of this was wrong bc thats only safe to do on the hole_tp side and apply_immut is already done to the hole before then anyways
Sourcepub fn unify(&mut self, t1: &TypeRef, t2: &TypeRef) -> UnifyResult
pub fn unify(&mut self, t1: &TypeRef, t2: &TypeRef) -> UnifyResult
Normal unification. Does not do the amortizing step of the unionfind (but may mutate it still). See unify_cached() for amortized unionfind. Note that this is likely not slower than unify_cached() in most cases.
Trait Implementations§
impl Eq for TypeSet
impl StructuralPartialEq for TypeSet
Auto Trait Implementations§
impl Freeze for TypeSet
impl RefUnwindSafe for TypeSet
impl Send for TypeSet
impl Sync for TypeSet
impl Unpin for TypeSet
impl UnwindSafe for TypeSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.