Macro swipl::prelude::unifiable

source ·
macro_rules! unifiable {
    (($self_:ident : $t:ty, $term_: ident) => $b: block) => { ... };
}
Expand description

Easily implement Unifiable.

Example:

struct Foo {num: u64}

unifiable!{
    (self:Foo, term) => {
        // Body needs to return a bool indicating success or failure.
        // Failure may also be an exception. The wrapper will check for this.
        attempt(term.unify(self.num)).unwrap_or(false)
    }
}

fn do_something(term: &Term) -> PrologResult<()> {
    term.unify(Foo{num:42})
}