Struct swipl::functor::Functor

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

A wrapper for a prolog functor.

Implementations§

source§

impl Functor

source

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.

source

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.

source

pub fn functor_ptr(&self) -> functor_t

Return the underlying functor_t which SWI-Prolog uses to refer to the functor.

source

pub fn with_name<F, R>(&self, func: F) -> R
where F: Fn(&Atom) -> 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.

source

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.

source

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.

source

pub fn arity(&self) -> u16

Retrieve the arity of this functor.

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

Trait Implementations§

source§

impl Clone for Functor

source§

fn clone(&self) -> Functor

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 Debug for Functor

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Functor

source§

fn eq(&self, other: &Functor) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> TermGetable for Functor

source§

fn get(term: &Term<'_>) -> Option<Self>

Get data from a term reference. Read more
source§

fn name() -> &'static str

Get the name of this data type for use in exception reporting.
source§

impl<'a> TermPutable for Functor

source§

fn put(&self, term: &Term<'_>)

Put data into the term reference. Read more
source§

impl<'a> Unifiable for Functor

source§

fn unify(&self, term: &Term<'_>) -> bool

Unify this data with the given term reference. Read more
source§

impl Copy for Functor

source§

impl Eq for Functor

source§

impl StructuralEq for Functor

source§

impl StructuralPartialEq for Functor

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.