Struct swipl::functor::LazyFunctor
source · pub struct LazyFunctor { /* private fields */ }
Expand description
A struct which provides a way to delay and cache functor creation.
This struct wraps a static string and an arity and uses it to
construct a swipl functor on the first invocation of
as_functor
. Subsequent invocations will reuse the earlier
constructed functor.
The purpose of this struct is to back the implementation of the
functor!
macro, but it’s also usable on its own.
Implementations§
source§impl LazyFunctor
impl LazyFunctor
sourcepub const fn new(name: &'static str, arity: u16) -> Self
pub const fn new(name: &'static str, arity: u16) -> Self
Create a new LazyFunctor.
This constructor is const, as all it does is set up the struct. No actual calls into SWI-Prolog happen at this stage.
sourcepub fn as_functor(&self) -> Functor
pub fn as_functor(&self) -> Functor
Create a functor, or return an earlier created functor.
On first call, this will call swipl to create a functor. Subsequent calls will reuse the functor that was retrieved before.
Auto Trait Implementations§
impl RefUnwindSafe for LazyFunctor
impl Send for LazyFunctor
impl Sync for LazyFunctor
impl Unpin for LazyFunctor
impl UnwindSafe for LazyFunctor
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more