pub struct Offset<T> { /* private fields */ }
Expand description
An object with an usize
offset for variables.
For example, when we want to create a fresh clause copy,
instead of creating a new clause by applying an offset to every variable (taking linear time),
we simply wrap a clause pointer with an Offset
(taking constant time).
This approach (wrapping objects in an Offset
) also avoids
mixing up offsets for different objects or
forgetting to consider an offset.
A principal design idea of this type is that we should not be able to obtain the original, non-offset object once it is offset. This is to prevent that the offset is “forgotten”.
Implementations§
source§impl<'t, C> Offset<&'t Term<C, usize>>
impl<'t, C> Offset<&'t Term<C, usize>>
sourcepub fn whnf(self, sub: &Sub<'t, C>) -> Self
pub fn whnf(self, sub: &Sub<'t, C>) -> Self
Substitute the head of the term until a fix point is reached.
let mut sub: Sub<&str> = Sub::default();
sub.set_dom_max(3);
let tm0: Term<&str, _> = Term::V(0);
let tm1: Term<&str, _> = Term::V(1);
let ot0 = OTerm::new(2, &tm0);
let ot1 = OTerm::new(0, &tm1);
sub.insert(2, ot1);
// 0+2 should be substituted to 1+0 and terminate there
assert!(ot0.whnf(&sub).ptr_eq(ot1))
source§impl<'t, C: Eq> Offset<&'t Args<Term<C, usize>>>
impl<'t, C: Eq> Offset<&'t Args<Term<C, usize>>>
Trait Implementations§
source§impl<'t, P: Display, C: Display> Display for Offset<&'t Contrapositive<&'t Lit<P, C, usize>>>
impl<'t, P: Display, C: Display> Display for Offset<&'t Contrapositive<&'t Lit<P, C, usize>>>
source§impl<'t, L: 't, M: 't> Display for Offset<&'t LitMat<L, M>>where
Offset<&'t L>: Display,
Offset<&'t M>: Display,
impl<'t, L: 't, M: 't> Display for Offset<&'t LitMat<L, M>>where Offset<&'t L>: Display, Offset<&'t M>: Display,
source§impl<T, I: IntoIterator<Item = T>> IntoIterator for Offset<I>
impl<T, I: IntoIterator<Item = T>> IntoIterator for Offset<I>
Convert an offset of a collection of T
s to a collection of offset T
s.
impl<T: Copy> Copy for Offset<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Offset<T>where T: RefUnwindSafe,
impl<T> Send for Offset<T>where T: Send,
impl<T> Sync for Offset<T>where T: Sync,
impl<T> Unpin for Offset<T>where T: Unpin,
impl<T> UnwindSafe for Offset<T>where T: 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