pub fn new_predicate(&self, pred: &Predicate) -> Result<()> {

        // Verify we have at least one argument
        if pred.fields.len() == 0 {
            bail!(ErrorKind::Invalid(
                "Predicates must have at least one argument.".to_string(),
            ));
        }

        // Check for existing predicates/type issues
        match self.fact_db.get_predicate(&pred.name) {
            Some(p) => {
                if pred.fields == p.fields {
                    // TODO should this be return ()
                    ()
                } else {
                    bail!(ErrorKind::Type(
                        format!("{:?} != {:?}", pred.fields, p.fields),
                    ));
                }
            }
            None => (),
        }

        Ok(self.fact_db.new_predicate(pred)?)
    }
/// Register a new predicate
/// This defines the type signature of a predicate and persists it
///
/// * Predicates must have at least one argument
/// * Predicates must have a unique name
/// * While using the `pg` backend, their name must be lowercase ascii or '_'
Register a new predicate
This defines the type signature of a predicate and persists it

Predicates must have at least one argument
Predicates must have a unique name
While using the `pg` backend, their name must be lowercase ascii or '_'
Register a new predicate This defines the type signature of a predicate and persists it Predicates must have at least one argument Predicates must have a unique name While using the ` pg ` backend their name must be lowercase ascii or ' _ '
pub fn new_predicate(&self, pred: &Predicate) -> Result<()> {
        // Verify we have at least one argument
        if pred.fields.len() == 0 {
            bail!(ErrorKind::Invalid(
                "Predicates must have at least one argument.".to_string(),
            ));
        }
        // Check for existing predicates/type issues
        match self.fact_db.get_predicate(&pred.name) {
            Some(p) => {
                if pred.fields == p.fields {
                    // TODO should this be return ()
                    ()
                } else {
                    bail!(ErrorKind::Type(
                        format!("{:?} != {:?}", pred.fields, p.fields),
                    ));
                }
            }
            None => (),
        }
        Ok(self.fact_db.new_predicate(pred)?)
    }
pub fn new_predicate ( & self , pred : & Predicate ) -> Result < ( ) > { // Verify we have at least one argument if pred . fields . len ( ) == 0 { bail ! ( ErrorKind Invalid ( " " to_string ( ) ) ) ; } // Check for existing predicates/type issues match self . fact_db . get_predicate ( & pred . name ) { Some ( p ) => { if pred . fields == p . fields { // TODO should this be return () ( ) } else { bail ! ( ErrorKind Type ( format ( " " pred fields p fields ) ) ) ; } } None => ( ) , } Ok ( self . fact_db . new_predicate ( pred ) ? ) }
Register a new predicate
This defines the type signature of a predicate and persists it
Register a new predicate This defines the type signature of a predicate and persists it
&self
pred
&Predicate
&self
pred
&Predicate