Struct swipl::predicate::Predicate

source ·
pub struct Predicate { /* private fields */ }
Expand description

A wrapper for a prolog predicate.

Implementations§

source§

impl Predicate

source

pub unsafe fn wrap(predicate: predicate_t) -> Self

Wrap a predicate_t, which is how the SWI-Prolog fli represents predicates.

Safety

This is unsafe because no check is done to ensure that the predicate_t indeed points at a valid predicate. The caller will have to ensure that this is the case.

source

pub fn new(functor: Functor, module: Module) -> Self

Create a new predicate from the given functor and module.

This will panic if no prolog engine is active on this thread.

source

pub fn predicate_ptr(&self) -> predicate_t

Return the underlying predicate_t which SWI-Prolog uses to refer to the predicate.

source

pub fn with_name<F, R>(&self, func: F) -> R
where F: Fn(&Atom) -> R,

Retrieve the name of this predicate as an atom and pass it into the given function.

The atom does not outlive this call, and the reference count is never incremented. This may be slightly faster in some cases than returning the name directly.

This will panic if no prolog engine is active on this thread.

source

pub fn name(&self) -> Atom

Retrieve the name of this predicate as an atom.

This will panic if no prolog engine is active on this thread.

source

pub fn name_string(&self) -> String

Retrieve the name of this predicate as a string.

This will panic if no prolog engine is active on this thread.

source

pub fn arity(&self) -> u16

Retrieve the arity of this predicate.

This will panic if no prolog engine is active on this thread.

source

pub fn module(&self) -> Module

Retrieve the module of this predicate.

this will panic if no prolog engine is active on this thread.

Trait Implementations§

source§

impl Clone for Predicate

source§

fn clone(&self) -> Predicate

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Copy for Predicate

source§

impl Send for Predicate

source§

impl Sync for Predicate

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.