pub struct UnificationTable<S>where
S: UnificationStoreBase,{
values: S,
}
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>>
orInPlaceUnificationTable<K>
):- This is the standard mutable mode, where the array is modified in place.
- To do backtracking, you can employ the
snapshot
androllback_to
methods.
- persistent (
UnificationTable<Persistent<K>>
orPersistentUnificationTable<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.
Fields§
§values: S
Implementations§
Source§impl<S> UnificationTable<S>where
S: UnificationStoreBase + Default,
impl<S> UnificationTable<S>where
S: UnificationStoreBase + Default,
pub fn new() -> UnificationTable<S>
Source§impl<S> UnificationTable<S>where
S: UnificationStore,
impl<S> UnificationTable<S>where
S: UnificationStore,
Sourcepub fn snapshot(&mut self) -> Snapshot<S>
pub fn snapshot(&mut self) -> Snapshot<S>
Starts a new snapshot. Each snapshot must be either rolled back or committed in a “LIFO” (stack) order.
Sourcepub fn rollback_to(&mut self, snapshot: Snapshot<S>)
pub fn rollback_to(&mut self, snapshot: Snapshot<S>)
Reverses all changes since the last snapshot. Also removes any keys that have been created since then.
Sourcepub fn commit(&mut self, snapshot: Snapshot<S>)
pub fn commit(&mut self, snapshot: Snapshot<S>)
Commits all changes since the last snapshot. Of course, they can still be undone if there is a snapshot further out.
Sourcepub fn vars_since_snapshot(
&self,
snapshot: &Snapshot<S>,
) -> Range<<S as UnificationStoreBase>::Key>
pub fn vars_since_snapshot( &self, snapshot: &Snapshot<S>, ) -> Range<<S as UnificationStoreBase>::Key>
Returns the keys of all variables created since the snapshot
.
Source§impl<S> UnificationTable<S>where
S: UnificationStoreBase,
impl<S> UnificationTable<S>where
S: UnificationStoreBase,
Source§impl<S> UnificationTable<S>where
S: UnificationStoreMut,
impl<S> UnificationTable<S>where
S: UnificationStoreMut,
Sourcepub fn new_key(
&mut self,
value: <S as UnificationStoreBase>::Value,
) -> <S as UnificationStoreBase>::Key
pub fn new_key( &mut self, value: <S as UnificationStoreBase>::Value, ) -> <S as UnificationStoreBase>::Key
Creates a fresh key with the given value.
Sourcepub fn reserve(&mut self, num_new_keys: usize)
pub fn reserve(&mut self, num_new_keys: usize)
Reserve memory for num_new_keys
to be created. Does not
actually create the new keys; you must then invoke new_key
.
Sourcepub fn reset_unifications(
&mut self,
value: impl FnMut(<S as UnificationStoreBase>::Key) -> <S as UnificationStoreBase>::Value,
)
pub fn reset_unifications( &mut self, value: impl FnMut(<S as UnificationStoreBase>::Key) -> <S as UnificationStoreBase>::Value, )
Clears all unifications that have been performed, resetting to the initial state. The values of each variable are given by the closure.
Source§impl<S, K, V> UnificationTable<S>
impl<S, K, V> UnificationTable<S>
//////////////////////////////////////////////////////////////////////// Public API
Sourcepub fn try_probe_value<'a, K1>(&'a self, id: K1) -> Option<&'a V>where
K1: Into<K>,
K: 'a,
pub fn try_probe_value<'a, K1>(&'a self, id: K1) -> Option<&'a V>where
K1: Into<K>,
K: 'a,
Obtains current value for key without any pointer chasing; may return None
if key has been union’d.
Source§impl<S, K, V> UnificationTable<S>
impl<S, K, V> UnificationTable<S>
Sourcepub fn union<K1, K2>(&mut self, a_id: K1, b_id: K2)
pub fn union<K1, K2>(&mut self, a_id: K1, b_id: K2)
Unions two keys without the possibility of failure; only
applicable when unify values use NoError
as their error
type.
Sourcepub fn union_value<K1>(&mut self, id: K1, value: V)
pub fn union_value<K1>(&mut self, id: K1, value: V)
Unions a key and a value without the possibility of failure;
only applicable when unify values use NoError
as their error
type.
Sourcepub fn unioned<K1, K2>(&mut self, a_id: K1, b_id: K2) -> bool
pub fn unioned<K1, K2>(&mut self, a_id: K1, b_id: K2) -> bool
Given two keys, indicates whether they have been unioned together.
Sourcepub fn find<K1>(&mut self, id: K1) -> Kwhere
K1: Into<K>,
pub fn find<K1>(&mut self, id: K1) -> Kwhere
K1: Into<K>,
Given a key, returns the (current) root key.
Sourcepub fn unify_var_var<K1, K2>(
&mut self,
a_id: K1,
b_id: K2,
) -> Result<(), <V as UnifyValue>::Error>
pub fn unify_var_var<K1, K2>( &mut self, a_id: K1, b_id: K2, ) -> Result<(), <V as UnifyValue>::Error>
Unions together two variables, merging their values. If merging the values fails, the error is propagated and this method has no effect.
Sourcepub fn unify_var_value<K1>(
&mut self,
a_id: K1,
b: V,
) -> Result<(), <V as UnifyValue>::Error>where
K1: Into<K>,
pub fn unify_var_value<K1>(
&mut self,
a_id: K1,
b: V,
) -> Result<(), <V as UnifyValue>::Error>where
K1: Into<K>,
Sets the value of the key a_id
to b
, attempting to merge
with the previous value.
Sourcepub fn probe_value<K1>(&mut self, id: K1) -> Vwhere
K1: Into<K>,
pub fn probe_value<K1>(&mut self, id: K1) -> Vwhere
K1: Into<K>,
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) -> Vwhere
K1: Into<K>,
Trait Implementations§
Source§impl<S> Clone for UnificationTable<S>where
S: Clone + UnificationStoreBase,
impl<S> Clone for UnificationTable<S>where
S: Clone + UnificationStoreBase,
Source§fn clone(&self) -> UnificationTable<S>
fn clone(&self) -> UnificationTable<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<S> Debug for UnificationTable<S>where
S: Debug + UnificationStoreBase,
impl<S> Debug for UnificationTable<S>where
S: Debug + UnificationStoreBase,
Source§impl<S> Default for UnificationTable<S>where
S: Default + UnificationStoreBase,
impl<S> Default for UnificationTable<S>where
S: Default + UnificationStoreBase,
Source§fn default() -> UnificationTable<S>
fn default() -> UnificationTable<S>
Auto Trait Implementations§
impl<S> DynSend for UnificationTable<S>where
S: DynSend,
impl<S> DynSync for UnificationTable<S>where
S: DynSync,
impl<S> Freeze for UnificationTable<S>where
S: Freeze,
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§
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.