/// Adds a new fact to the database
/// If the fact is already present, a new copy will not be added.
///
/// * The relevant predicate must already be registered
/// * The fact must be correctly typed
Adds a new fact to the database
If the fact is already present, a new copy will not be added.

The relevant predicate must already be registered
The fact must be correctly typed
Adds a new fact to the database If the fact is already present a new copy will not be added . The relevant predicate must already be registered The fact must be correctly typed
pub fn new_fact(&mut self, fact: &Fact) -> Result<()> {
        match self.fact_db.get_predicate(&fact.pred_name) {
            Some(ref pred) => {
                if (fact.args.len() != pred.fields.len()) ||
                    (!fact.args.iter().zip(pred.fields.iter()).all(
                        |(val, field)| {
                            val.type_() == field.type_.clone()
                        },
                    ))
                {
                    bail!(ErrorKind::Type(format!(
                        "Fact ({:?}) does not \
                                                   match predicate ({:?})",
                        fact,
                        pred.fields
                    )));
                }
            }
            None => bail!(ErrorKind::Invalid("Predicate not registered".to_string())),
        }
        {
            if self.fact_db.insert_fact(&fact)?.is_some() {
                let deps = self.get_dep_rules(&fact.pred_name);
                for signal in deps.borrow().iter() {
                    signal.signal();
                }
            }
            Ok(())
        }
    }
pub fn new_fact ( & mut self , fact : & Fact ) -> Result < ( ) > { match self . fact_db . get_predicate ( & fact . pred_name ) { Some ( ref pred ) => { if ( fact . args . len ( ) != pred . fields . len ( ) ) || ( ! fact . args . iter ( ) . zip ( pred . fields . iter ( ) ) . all ( | ( val , field ) | { val . type_ ( ) == field . type_ . clone ( ) } , ) ) { bail ! ( ErrorKind Type ( format ( " \
 " fact pred fields ) ) ) ; } } None => bail ! ( ErrorKind Invalid ( " " to_string ( ) ) ) , } { if self . fact_db . insert_fact ( & fact ) ? . is_some ( ) { let deps = self . get_dep_rules ( & fact . pred_name ) ; for signal in deps . borrow ( ) . iter ( ) { signal . signal ( ) ; } } Ok ( ( ) ) } }
Adds a new fact to the database
If the fact is already present, a new copy will not be added.
Adds a new fact to the database If the fact is already present a new copy will not be added .
&mut self
fact
&Fact