fn external_call_result(&mut self, call_id: u64, term: Option<Term>) -> PolarResult<()> {
        // TODO: Open question if we need to pass errors back down to rust.
        // For example what happens if the call asked for a field that doesn't exist?

        if let Some(value) = term {
            self.log_with(|| format!("=> {}", value.to_string()), &[]);

            self.rebind_external_answer(
                &self
                    .call_id_symbols
                    .get(&call_id)
                    .expect("unregistered external call ID")
                    .clone(),
                value,
            );
        } else {
            self.log("=> No more results.", &[]);

            // No more results. Clean up, cut out the retry alternative,
            // and backtrack.
            self.call_id_symbols.remove(&call_id).expect("bad call ID");

            let check_error = if let Some(goal) = self.goals.last() {
                matches!(*(*goal), Goal::CheckError)
            } else {
                false
            };

            self.push_goal(Goal::Backtrack)?;
            self.push_goal(Goal::Cut {
                choice_index: self.choices.len() - 1,
            })?;

            if check_error {
                self.push_goal(Goal::CheckError)?;
            }
        }
        Ok(())
    }
/// Handle an external result provided by the application.
///
/// If the value is `Some(_)` then we have a result, and bind the
/// symbol associated with the call ID to the result value. If the
/// value is `None` then the external has no (more) results, so we
/// backtrack to the choice point left by `Goal::LookupExternal`.
Handle an external result provided by the application.
If the value is `Some(_)` then we have a result, and bind the
symbol associated with the call ID to the result value. If the
value is `None` then the external has no (more) results, so we
backtrack to the choice point left by `Goal::LookupExternal`.
Handle an external result provided by the application . If the value is ` Some ( _ ) ` then we have a result and bind the symbol associated with the call ID to the result value . If the value is ` None ` then the external has no ( more ) results so we backtrack to the choice point left by ` Goal :: LookupExternal ` .
fn external_call_result(&mut self, call_id: u64, term: Option<Term>) -> PolarResult<()> {
        // TODO: Open question if we need to pass errors back down to rust.
        // For example what happens if the call asked for a field that doesn't exist?
        if let Some(value) = term {
            self.log_with(|| format!("=> {}", value.to_string()), &[]);
            self.rebind_external_answer(
                &self
                    .call_id_symbols
                    .get(&call_id)
                    .expect("unregistered external call ID")
                    .clone(),
                value,
            );
        } else {
            self.log("=> No more results.", &[]);
            // No more results. Clean up, cut out the retry alternative,
            // and backtrack.
            self.call_id_symbols.remove(&call_id).expect("bad call ID");
            let check_error = if let Some(goal) = self.goals.last() {
                matches!(*(*goal), Goal::CheckError)
            } else {
                false
            };
            self.push_goal(Goal::Backtrack)?;
            self.push_goal(Goal::Cut {
                choice_index: self.choices.len() - 1,
            })?;
            if check_error {
                self.push_goal(Goal::CheckError)?;
            }
        }
        Ok(())
    }
fn external_call_result ( & mut self , call_id : u64 , term : Option < Term > ) -> PolarResult < ( ) > { // TODO: Open question if we need to pass errors back down to rust. // For example what happens if the call asked for a field that doesn't exist? if let Some ( value ) = term { self . log_with ( | | format ! ( " " value to_string ( ) ) , & [ ] ) ; self . rebind_external_answer ( & self . call_id_symbols . get ( & call_id ) . expect ( " " ) . clone ( ) , value , ) ; } else { self . log ( " " , & [ ] ) ; // No more results. Clean up, cut out the retry alternative, // and backtrack. self . call_id_symbols . remove ( & call_id ) . expect ( " " ) ; let check_error = if let Some ( goal ) = self . goals . last ( ) { matches ! ( ( goal ) Goal CheckError ) } else { false } ; self . push_goal ( Goal :: Backtrack ) ? ; self . push_goal ( Goal :: Cut { choice_index : self . choices . len ( ) - 1 , } ) ? ; if check_error { self . push_goal ( Goal :: CheckError ) ? ; } } Ok ( ( ) ) }
Handle an external result provided by the application.
Handle an external result provided by the application .
&mut self
call_id
u64
term
Option<Term>