pub struct UnionFindTable { /* private fields */ }Expand description
Flat union-find inference variable table reusable across functions via Self::clear.
Implementations§
Source§impl UnionFindTable
impl UnionFindTable
pub fn with_capacity(cap: usize) -> Self
pub fn clear(&mut self)
pub fn var_count(&self) -> usize
Sourcepub fn new_var(
&mut self,
arena: &mut InferTyArena,
kind: TyVarKind,
) -> (TyVarId, InferTyId)
pub fn new_var( &mut self, arena: &mut InferTyArena, kind: TyVarKind, ) -> (TyVarId, InferTyId)
Allocates a fresh inference variable and its InferTyId wrapper inside arena.
pub fn start_snapshot(&mut self) -> InferSnapshot
pub fn commit(&mut self, snap: InferSnapshot)
pub fn rollback_to(&mut self, snap: InferSnapshot)
Sourcepub fn probe_var(
&mut self,
var: TyVarId,
) -> Result<InferTyId, (TyVarId, TyVarKind, u8, InferTyId)>
pub fn probe_var( &mut self, var: TyVarId, ) -> Result<InferTyId, (TyVarId, TyVarKind, u8, InferTyId)>
Finds the current representative of var with snapshot-aware path halving/compression.
Sourcepub fn probe_var_imm(
&self,
var: TyVarId,
) -> Result<InferTyId, (TyVarId, TyVarKind)>
pub fn probe_var_imm( &self, var: TyVarId, ) -> Result<InferTyId, (TyVarId, TyVarKind)>
Immutable read without path compression (safe for diagnostics and assertions).
Sourcepub fn shallow_resolve(
&mut self,
arena: &InferTyArena,
ty: InferTyId,
) -> InferTyId
pub fn shallow_resolve( &mut self, arena: &InferTyArena, ty: InferTyId, ) -> InferTyId
Peels chained Infer(v) indirections until reaching a concrete type or an unbound root Infer(root).
Sourcepub fn occurs_in(
&mut self,
arena: &InferTyArena,
needle_root: TyVarId,
ty: InferTyId,
) -> bool
pub fn occurs_in( &mut self, arena: &InferTyArena, needle_root: TyVarId, ty: InferTyId, ) -> bool
Checks whether needle_root appears anywhere inside ty (O(1) fast path when !has_infer()).
Sourcepub fn deep_resolve(
&mut self,
arena: &mut InferTyArena,
ty: InferTyId,
fallback_unbound: bool,
) -> InferTyId
pub fn deep_resolve( &mut self, arena: &mut InferTyArena, ty: InferTyId, fallback_unbound: bool, ) -> InferTyId
Recursively substitutes solved inference variables (O(1) when !has_infer()).
When fallback_unbound is true, maps {integer} -> i32, {float} -> f64, _ -> {unknown}.
Trait Implementations§
Source§impl Debug for UnionFindTable
impl Debug for UnionFindTable
Auto Trait Implementations§
impl Forget for UnionFindTable
impl Freeze for UnionFindTable
impl Move for UnionFindTable
impl RefUnwindSafe for UnionFindTable
impl Send for UnionFindTablewhere
RawVecInner: Send,
impl Sync for UnionFindTablewhere
RawVecInner: Sync,
impl Unpin for UnionFindTable
impl UnsafeUnpin for UnionFindTablewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<VarSlot>: UnsafeUnpin,
PhantomData<UndoEntry>: UnsafeUnpin,
impl UnwindSafe for UnionFindTablewhere
RawVecInner: UnwindSafe,
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
Mutably borrows from an owned value. Read more