pub enum Callable {
Native(Function),
Custom(Arc<dyn Fn(&mut Context<'_>, &[Value]) -> Result<Value, Error> + Send + Sync>),
}
Expand description
Callable value.
Variants§
Native(Function)
Custom(Arc<dyn Fn(&mut Context<'_>, &[Value]) -> Result<Value, Error> + Send + Sync>)
Implementations§
Source§impl Callable
impl Callable
Sourcepub fn as_native_mut(&mut self) -> Option<&mut Function>
pub fn as_native_mut(&mut self) -> Option<&mut Function>
Optionally returns mutable references to the inner fields if this is a Callable::Native
, otherwise None
Sourcepub fn as_native(&self) -> Option<&Function>
pub fn as_native(&self) -> Option<&Function>
Optionally returns references to the inner fields if this is a Callable::Native
, otherwise None
Sourcepub fn into_native(self) -> Result<Function, Self>
pub fn into_native(self) -> Result<Function, Self>
Returns the inner fields if this is a Callable::Native
, otherwise returns back the enum in the Err
case of the result
Sourcepub fn as_custom_mut(
&mut self,
) -> Option<&mut Arc<dyn Fn(&mut Context<'_>, &[Value]) -> Result<Value, EvalError> + Send + Sync>>
pub fn as_custom_mut( &mut self, ) -> Option<&mut Arc<dyn Fn(&mut Context<'_>, &[Value]) -> Result<Value, EvalError> + Send + Sync>>
Optionally returns mutable references to the inner fields if this is a Callable::Custom
, otherwise None
Trait Implementations§
Source§impl From<Arc<dyn Fn(&mut Context<'_>, &[Value]) -> Result<Value, Error> + Send + Sync>> for Callable
impl From<Arc<dyn Fn(&mut Context<'_>, &[Value]) -> Result<Value, Error> + Send + Sync>> for Callable
Auto Trait Implementations§
impl Freeze for Callable
impl !RefUnwindSafe for Callable
impl Send for Callable
impl Sync for Callable
impl Unpin for Callable
impl !UnwindSafe for Callable
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more