Struct rustc_ap_rustc_data_structures::unify::UnificationTable[][src]

pub struct UnificationTable<S> where
    S: UnificationStoreBase
{ /* fields omitted */ }
Expand description

Table of unification keys and their values. You must define a key type K that implements the UnifyKey trait. Unification tables can be used in two-modes:

  • in-place (UnificationTable<InPlace<K>> or InPlaceUnificationTable<K>):
    • This is the standard mutable mode, where the array is modified in place.
    • To do backtracking, you can employ the snapshot and rollback_to methods.
  • persistent (UnificationTable<Persistent<K>> or PersistentUnificationTable<K>):
    • In this mode, we use a persistent vector to store the data, so that cloning the table is an O(1) operation.
    • This implies that ordinary operations are quite a bit slower though.
    • Requires the persistent feature be selected in your Cargo.toml file.

Implementations

impl<K> UnificationTable<InPlace<K, Vec<VarValue<K>, Global>, ()>> where
    K: UnifyKey
[src]

pub fn with_log<L>(
    &'a mut self,
    undo_log: L
) -> UnificationTable<InPlace<K, &'a mut Vec<VarValue<K>, Global>, L>> where
    L: UndoLogs<UndoLog<Delegate<K>>>, 
[src]

Creates a UnificationTable using an external undo_log, allowing mutating methods to be called if L does not implement UndoLogs

impl<S> UnificationTable<S> where
    S: UnificationStoreBase + Default
[src]

pub fn new() -> UnificationTable<S>[src]

impl<S> UnificationTable<S> where
    S: UnificationStore
[src]

pub fn snapshot(&mut self) -> Snapshot<S>[src]

Starts a new snapshot. Each snapshot must be either rolled back or committed in a “LIFO” (stack) order.

pub fn rollback_to(&mut self, snapshot: Snapshot<S>)[src]

Reverses all changes since the last snapshot. Also removes any keys that have been created since then.

pub fn commit(&mut self, snapshot: Snapshot<S>)[src]

Commits all changes since the last snapshot. Of course, they can still be undone if there is a snapshot further out.

pub fn vars_since_snapshot(
    &self,
    snapshot: &Snapshot<S>
) -> Range<<S as UnificationStoreBase>::Key>

Notable traits for Range<A>

impl<A> Iterator for Range<A> where
    A: Step
type Item = A;
[src]

Returns the keys of all variables created since the snapshot.

impl<S> UnificationTable<S> where
    S: UnificationStoreBase
[src]

pub fn len(&self) -> usize[src]

Returns the number of keys created so far.

impl<S> UnificationTable<S> where
    S: UnificationStoreMut
[src]

pub fn new_key(
    &mut self,
    value: <S as UnificationStoreBase>::Value
) -> <S as UnificationStoreBase>::Key
[src]

Starts a new snapshot. Each snapshot must be either Creates a fresh key with the given value.

pub fn reserve(&mut self, num_new_keys: usize)[src]

Reserve memory for num_new_keys to be created. Does not actually create the new keys; you must then invoke new_key.

pub fn reset_unifications(
    &mut self,
    value: impl FnMut(<S as UnificationStoreBase>::Key) -> <S as UnificationStoreBase>::Value
)
[src]

Clears all unifications that have been performed, resetting to the initial state. The values of each variable are given by the closure.

impl<S, K, V> UnificationTable<S> where
    K: UnifyKey<Value = V>,
    V: UnifyValue,
    S: UnificationStoreMut<Key = K, Value = V>, 
[src]

//////////////////////////////////////////////////////////////////////// Public API

pub fn union<K1, K2>(&mut self, a_id: K1, b_id: K2) where
    V: UnifyValue<Error = NoError>,
    K1: Into<K>,
    K2: Into<K>, 
[src]

Unions two keys without the possibility of failure; only applicable when unify values use NoError as their error type.

pub fn union_value<K1>(&mut self, id: K1, value: V) where
    V: UnifyValue<Error = NoError>,
    K1: Into<K>, 
[src]

Unions a key and a value without the possibility of failure; only applicable when unify values use NoError as their error type.

pub fn unioned<K1, K2>(&mut self, a_id: K1, b_id: K2) -> bool where
    K1: Into<K>,
    K2: Into<K>, 
[src]

Given two keys, indicates whether they have been unioned together.

pub fn find<K1>(&mut self, id: K1) -> K where
    K1: Into<K>, 
[src]

Given a key, returns the (current) root key.

pub fn unify_var_var<K1, K2>(
    &mut self,
    a_id: K1,
    b_id: K2
) -> Result<(), <V as UnifyValue>::Error> where
    K1: Into<K>,
    K2: Into<K>, 
[src]

Unions together two variables, merging their values. If merging the values fails, the error is propagated and this method has no effect.

pub fn unify_var_value<K1>(
    &mut self,
    a_id: K1,
    b: V
) -> Result<(), <V as UnifyValue>::Error> where
    K1: Into<K>, 
[src]

Sets the value of the key a_id to b, attempting to merge with the previous value.

pub fn probe_value<K1>(&mut self, id: K1) -> V where
    K1: Into<K>, 
[src]

Returns the current value for the given key. If the key has been union’d, this will give the value from the current root.

pub fn inlined_probe_value<K1>(&mut self, id: K1) -> V where
    K1: Into<K>, 
[src]

Trait Implementations

impl<S> Clone for UnificationTable<S> where
    S: Clone + UnificationStoreBase
[src]

pub fn clone(&self) -> UnificationTable<S>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<S> Debug for UnificationTable<S> where
    S: Debug + UnificationStoreBase
[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl<S> Default for UnificationTable<S> where
    S: Default + UnificationStoreBase
[src]

pub fn default() -> UnificationTable<S>[src]

Returns the “default value” for a type. Read more

impl<K> Rollback<UndoLog<Delegate<K>>> for UnificationTable<InPlace<K, Vec<VarValue<K>, Global>, ()>> where
    K: UnifyKey
[src]

pub fn reverse(&mut self, undo: UndoLog<Delegate<K>>)[src]

Auto Trait Implementations

impl<S> RefUnwindSafe for UnificationTable<S> where
    S: RefUnwindSafe

impl<S> Send for UnificationTable<S> where
    S: Send

impl<S> Sync for UnificationTable<S> where
    S: Sync

impl<S> Unpin for UnificationTable<S> where
    S: Unpin

impl<S> UnwindSafe for UnificationTable<S> where
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]