pub fn bind(&mut self, var: &Symbol, val: Term) -> PolarResult<()> {
        if let Ok(symbol) = val.value().as_symbol() {
            self.bind_variables(var, symbol)?;
        } else if let BindingManagerVariableState::Partial(p) = self._variable_state(var) {
            if let Some(grounded) = p.ground(var.clone(), val.clone()) {
                self.add_binding(var, val.clone());
                self.constrain(&grounded)?;
            } else {
                return Err(RuntimeError::IncompatibleBindings {
                    msg: "Grounding failed".into(),
                }
                .into());
            }
        } else {
            if let BindingManagerVariableState::Bound(_) = self._variable_state(var) {
                return Err(RuntimeError::IncompatibleBindings {
                    msg: format!("Cannot rebind {:?}", var),
                }
                .into());
            }

            self.add_binding(var, val.clone());
        }

        // If the main binding succeeded, the follower binding must succeed.
        self.do_followers(|_, follower| follower.bind(var, val.clone()))
            .unwrap();

        Ok(())
    }
/// Bind `var` to `val`.
///
/// If the binding succeeds, Ok is returned. If the binding is *incompatible*
/// an error is returned.
///
/// A binding is considered *incompatible* if either:
///
/// 1. `var` is already bound to some value (rebindings are not allowed, even if the
///    rebinding is to the same value).
/// 2. `var` is constrained, and the new binding of `val` is not compatible with those
///    constraints.
///
/// If a binding is compatible, it is recorded. If the binding was to a ground value,
/// subsequent calls to `variable_state` or `deref` will return that value.
///
/// If the binding was between two variables, the two will always have the same value
/// or constraints going forward. Further, a unification constraint is recorded between
/// the two variables.
///
/// If either variable is bound in the future, both will be bound to that value
/// (`variable_state` and `deref` will return the same value).
///
/// If a binding between two variables is made, and one is bound and the other unbound, the
/// unbound variable will take the value of the bound one.
Bind `var` to `val`.
If the binding succeeds, Ok is returned. If the binding is *incompatible
an error is returned.

A binding is considered *incompatible* if either.

1. `var` is already bound to some value (rebindings are not allowed, even if the
rebinding is to the same value).
2. `var` is constrained, and the new binding of `val` is not compatible with those
constraints.

If a binding is compatible, it is recorded. If the binding was to a ground value,
subsequent calls to `variable_state` or `deref` will return that value.

If the binding was between two variables, the two will always have the same value
or constraints going forward. Further, a unification constraint is recorded between
the two variables.

If either variable is bound in the future, both will be bound to that value
(`variable_state` and `deref` will return the same value).

If a binding between two variables is made, and one is bound and the other unbound, the
unbound variable will take the value of the bound one.
Bind ` var ` to ` val ` . If the binding succeeds Ok is returned . If the binding is * incompatible an error is returned . A binding is considered * incompatible * if either . 1 . ` var ` is already bound to some value ( rebindings are not allowed even if the rebinding is to the same value ) . 2 . ` var ` is constrained and the new binding of ` val ` is not compatible with those constraints . If a binding is compatible it is recorded . If the binding was to a ground value subsequent calls to ` variable_state ` or ` deref ` will return that value . If the binding was between two variables the two will always have the same value or constraints going forward . Further a unification constraint is recorded between the two variables . If either variable is bound in the future both will be bound to that value ( ` variable_state ` and ` deref ` will return the same value ) . If a binding between two variables is made and one is bound and the other unbound the unbound variable will take the value of the bound one .
pub fn bind(&mut self, var: &Symbol, val: Term) -> PolarResult<()> {
        if let Ok(symbol) = val.value().as_symbol() {
            self.bind_variables(var, symbol)?;
        } else if let BindingManagerVariableState::Partial(p) = self._variable_state(var) {
            if let Some(grounded) = p.ground(var.clone(), val.clone()) {
                self.add_binding(var, val.clone());
                self.constrain(&grounded)?;
            } else {
                return Err(RuntimeError::IncompatibleBindings {
                    msg: "Grounding failed".into(),
                }
                .into());
            }
        } else {
            if let BindingManagerVariableState::Bound(_) = self._variable_state(var) {
                return Err(RuntimeError::IncompatibleBindings {
                    msg: format!("Cannot rebind {:?}", var),
                }
                .into());
            }
            self.add_binding(var, val.clone());
        }
        // If the main binding succeeded, the follower binding must succeed.
        self.do_followers(|_, follower| follower.bind(var, val.clone()))
            .unwrap();
        Ok(())
    }
pub fn bind ( & mut self , var : & Symbol , val : Term ) -> PolarResult < ( ) > { if let Ok ( symbol ) = val . value ( ) . as_symbol ( ) { self . bind_variables ( var , symbol ) ? ; } else if let BindingManagerVariableState :: Partial ( p ) = self . _variable_state ( var ) { if let Some ( grounded ) = p . ground ( var . clone ( ) , val . clone ( ) ) { self . add_binding ( var , val . clone ( ) ) ; self . constrain ( & grounded ) ? ; } else { return Err ( RuntimeError :: IncompatibleBindings { msg : " " . into ( ) , } . into ( ) ) ; } } else { if let BindingManagerVariableState :: Bound ( _ ) = self . _variable_state ( var ) { return Err ( RuntimeError :: IncompatibleBindings { msg : format ! ( " " var ) , } . into ( ) ) ; } self . add_binding ( var , val . clone ( ) ) ; } // If the main binding succeeded, the follower binding must succeed. self . do_followers ( | _ , follower | follower . bind ( var , val . clone ( ) ) ) . unwrap ( ) ; Ok ( ( ) ) }
Bind `var` to `val`.
Bind ` var ` to ` val ` .
&mut self
var
&Symbol
val
Term