pub struct Functor { /* private fields */ }
Expand description
A wrapper for a prolog functor.
Implementations§
source§impl Functor
impl Functor
sourcepub unsafe fn wrap(functor: functor_t) -> Self
pub unsafe fn wrap(functor: functor_t) -> Self
Wrap a functor_t
, which is how the SWI-Prolog fli represents functors.
Safety
This is unsafe because no check is done to ensure that the functor_t indeed points at a valid functor. The caller will have to ensure that this is the case.
sourcepub fn new<A: IntoAtom>(name: A, arity: u16) -> Functor
pub fn new<A: IntoAtom>(name: A, arity: u16) -> Functor
Create a new functor from the given name and arity.
This will panic if no prolog engine is active on this thread.
sourcepub fn functor_ptr(&self) -> functor_t
pub fn functor_ptr(&self) -> functor_t
Return the underlying functor_t
which SWI-Prolog uses to refer to the functor.
sourcepub fn with_name<F, R>(&self, func: F) -> R
pub fn with_name<F, R>(&self, func: F) -> R
Retrieve the name of this functor 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.
sourcepub fn name(&self) -> Atom
pub fn name(&self) -> Atom
Retrieve the name of this functor as an atom.
This will panic if no prolog engine is active on this thread.
sourcepub fn name_string(&self) -> String
pub fn name_string(&self) -> String
Retrieve the name of this functor as a string.
This will panic if no prolog engine is active on this thread.