fn unify(&self, env: &Binding, clause: &Clause, record: &Record) -> Option<Binding> {
        let mut new_env: Binding = env.clone();

        match clause.entity {
            Term::Bound(ref e) => {
                if *e != record.entity {
                    return None;
                }
            }
            Term::Unbound(ref var) => {
                match env.get(var) {
                    Some(e) => {
                        if *e != Value::Ref(record.entity) {
                            return None;
                        }
                    }
                    _ => {
                        new_env.insert(var.clone(), Value::Ref(record.entity));
                    }
                }
            }
        }

        match clause.attribute {
            Term::Bound(ref a) => {
                // The query will use an ident to refer to the attribute, but we need the
                // actual attribute entity.
                match self.ident_entity(a) {
                    Some(e) => {
                        if e != record.attribute {
                            return None;
                        }
                    }
                    _ => return None,
                }
            }
            Term::Unbound(ref var) => {
                match env.get(var) {
                    Some(e) => {
                        if *e != Value::Ref(record.attribute) {
                            return None;
                        }
                    }
                    _ => {
                        new_env.insert(var.clone(), Value::Ref(record.attribute));
                    }
                }
            }
        }

        match clause.value {
            Term::Bound(ref v) => {
                if *v != record.value {
                    return None;
                }
            }
            Term::Unbound(ref var) => {
                match env.get(var) {
                    Some(e) => {
                        if *e != record.value {
                            return None;
                        }
                    }
                    _ => {
                        new_env.insert(var.clone(), record.value.clone());
                    }
                }
            }
        }

        Some(new_env)
    }
/// Attempts to unify a new record and a clause with existing
/// bindings.  If bound fields in the clause match the record, then
/// any fields in the record which match an unbound clause will be
/// bound in the returned binding.  If bound fields in the clause
/// conflict with fields in the record, unification fails.
Attempts to unify a new record and a clause with existing
bindings.  If bound fields in the clause match the record, then
any fields in the record which match an unbound clause will be
bound in the returned binding.  If bound fields in the clause
conflict with fields in the record, unification fails.
Attempts to unify a new record and a clause with existing bindings . If bound fields in the clause match the record then any fields in the record which match an unbound clause will be bound in the returned binding . If bound fields in the clause conflict with fields in the record unification fails .
fn unify(&self, env: &Binding, clause: &Clause, record: &Record) -> Option<Binding> {
        let mut new_env: Binding = env.clone();
        match clause.entity {
            Term::Bound(ref e) => {
                if *e != record.entity {
                    return None;
                }
            }
            Term::Unbound(ref var) => {
                match env.get(var) {
                    Some(e) => {
                        if *e != Value::Ref(record.entity) {
                            return None;
                        }
                    }
                    _ => {
                        new_env.insert(var.clone(), Value::Ref(record.entity));
                    }
                }
            }
        }
        match clause.attribute {
            Term::Bound(ref a) => {
                // The query will use an ident to refer to the attribute, but we need the
                // actual attribute entity.
                match self.ident_entity(a) {
                    Some(e) => {
                        if e != record.attribute {
                            return None;
                        }
                    }
                    _ => return None,
                }
            }
            Term::Unbound(ref var) => {
                match env.get(var) {
                    Some(e) => {
                        if *e != Value::Ref(record.attribute) {
                            return None;
                        }
                    }
                    _ => {
                        new_env.insert(var.clone(), Value::Ref(record.attribute));
                    }
                }
            }
        }
        match clause.value {
            Term::Bound(ref v) => {
                if *v != record.value {
                    return None;
                }
            }
            Term::Unbound(ref var) => {
                match env.get(var) {
                    Some(e) => {
                        if *e != record.value {
                            return None;
                        }
                    }
                    _ => {
                        new_env.insert(var.clone(), record.value.clone());
                    }
                }
            }
        }
        Some(new_env)
    }
fn unify ( & self , env : & Binding , clause : & Clause , record : & Record ) -> Option < Binding > { let mut new_env : Binding = env . clone ( ) ; match clause . entity { Term :: Bound ( ref e ) => { if * e != record . entity { return None ; } } Term :: Unbound ( ref var ) => { match env . get ( var ) { Some ( e ) => { if * e != Value :: Ref ( record . entity ) { return None ; } } _ => { new_env . insert ( var . clone ( ) , Value :: Ref ( record . entity ) ) ; } } } } match clause . attribute { Term :: Bound ( ref a ) => { // The query will use an ident to refer to the attribute, but we need the // actual attribute entity. match self . ident_entity ( a ) { Some ( e ) => { if e != record . attribute { return None ; } } _ => return None , } } Term :: Unbound ( ref var ) => { match env . get ( var ) { Some ( e ) => { if * e != Value :: Ref ( record . attribute ) { return None ; } } _ => { new_env . insert ( var . clone ( ) , Value :: Ref ( record . attribute ) ) ; } } } } match clause . value { Term :: Bound ( ref v ) => { if * v != record . value { return None ; } } Term :: Unbound ( ref var ) => { match env . get ( var ) { Some ( e ) => { if * e != record . value { return None ; } } _ => { new_env . insert ( var . clone ( ) , record . value . clone ( ) ) ; } } } } Some ( new_env ) }
Attempts to unify a new record and a clause with existing
bindings.
Attempts to unify a new record and a clause with existing bindings .
&self
env
&Binding
clause
&Clause
record
&Record
&self
env
&Binding
clause
&Clause
record
&Record