pub fn unify_val(&self, var: &Var, val: T) -> PossibleStates<T> {
        match self.bindings.get(&var.index) {
            Some(slot) => {
                // if the variable has a slot (could be bound or unified with another variable)
                // see if it has a value.  if so, unify with the value, otherwise bind it to the value
                match self.slots.get(slot) {
                    Some(existing) => {
                        existing.unify(&val, self)
                    },
                    None => {
                        vec![State {
                            bindings: self.bindings.clone(),
                            slots: self.slots.insert(*slot, val).unwrap(),
                            .. *self
                        }]
                    }
                }
            },
            None => {
                // if this variable is not bound, make a new slot and binding for it
                let index = &var.index;
                vec![State {
                    bindings: self.bindings.insert(*index, *index).unwrap(),
                    slots: self.slots.insert(*index, val).unwrap(),
                    .. *self
                }]
            }
        }
    }
/// Attempts to unify a variable with a value.  If the variable is not bound,
/// returns a new state containing a binding to the value.  If the variable is
/// already bound, returns the unification of the two values.
Attempts to unify a variable with a value.  If the variable is not bound,
returns a new state containing a binding to the value.  If the variable is
already bound, returns the unification of the two values.
Attempts to unify a variable with a value . If the variable is not bound returns a new state containing a binding to the value . If the variable is already bound returns the unification of the two values .
pub fn unify_val(&self, var: &Var, val: T) -> PossibleStates<T> {
        match self.bindings.get(&var.index) {
            Some(slot) => {
                // if the variable has a slot (could be bound or unified with another variable)
                // see if it has a value.  if so, unify with the value, otherwise bind it to the value
                match self.slots.get(slot) {
                    Some(existing) => {
                        existing.unify(&val, self)
                    },
                    None => {
                        vec![State {
                            bindings: self.bindings.clone(),
                            slots: self.slots.insert(*slot, val).unwrap(),
                            .. *self
                        }]
                    }
                }
            },
            None => {
                // if this variable is not bound, make a new slot and binding for it
                let index = &var.index;
                vec![State {
                    bindings: self.bindings.insert(*index, *index).unwrap(),
                    slots: self.slots.insert(*index, val).unwrap(),
                    .. *self
                }]
            }
        }
    }
pub fn unify_val ( & self , var : & Var , val : T ) -> PossibleStates < T > { match self . bindings . get ( & var . index ) { Some ( slot ) => { // if the variable has a slot (could be bound or unified with another variable) // see if it has a value.  if so, unify with the value, otherwise bind it to the value match self . slots . get ( slot ) { Some ( existing ) => { existing . unify ( & val , self ) } , None => { vec ! [ State { bindings self bindings clone ( ) slots self slots insert ( slot val ) unwrap ( ) self } ] } } } , None => { // if this variable is not bound, make a new slot and binding for it let index = & var . index ; vec ! [ State { bindings self bindings insert ( index index ) unwrap ( ) slots self slots insert ( index val ) unwrap ( ) self } ] } } }
Attempts to unify a variable with a value.
Attempts to unify a variable with a value .
&self
var
&Var
val
T
&self
var
&Var
val
T