Trait arithmetic_eval::NativeFn

source ·
pub trait NativeFn<T> {
    // Required method
    fn evaluate(
        &self,
        args: Vec<SpannedValue<T>>,
        context: &mut CallContext<'_, T>,
    ) -> EvalResult<T>;
}
Expand description

Function on zero or more Values.

Native functions are defined in the Rust code and then can be used from the interpreted code. See fns module docs for different ways to define native functions.

Required Methods§

source

fn evaluate( &self, args: Vec<SpannedValue<T>>, context: &mut CallContext<'_, T>, ) -> EvalResult<T>

Executes the function on the specified arguments.

Trait Implementations§

source§

impl<T> Debug for dyn NativeFn<T>

source§

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

Formats the value using the given formatter. Read more

Implementors§

source§

impl<Num, F, Ret> NativeFn<Num> for FnWrapper<(Ret,), F, false>
where F: Fn() -> Ret, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret> NativeFn<Num> for FnWrapper<(Ret,), F, true>
where F: Fn(&mut CallContext<'_, Num>) -> Ret, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T> NativeFn<Num> for FnWrapper<(Ret, T), F, false>
where F: Fn(T) -> Ret, T: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T> NativeFn<Num> for FnWrapper<(Ret, T), F, true>
where F: Fn(&mut CallContext<'_, Num>, T) -> Ret, T: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U> NativeFn<Num> for FnWrapper<(Ret, T, U), F, false>
where F: Fn(T, U) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U> NativeFn<Num> for FnWrapper<(Ret, T, U), F, true>
where F: Fn(&mut CallContext<'_, Num>, T, U) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V> NativeFn<Num> for FnWrapper<(Ret, T, U, V), F, false>
where F: Fn(T, U, V) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V> NativeFn<Num> for FnWrapper<(Ret, T, U, V), F, true>
where F: Fn(&mut CallContext<'_, Num>, T, U, V) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W), F, false>
where F: Fn(T, U, V, W) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W), F, true>
where F: Fn(&mut CallContext<'_, Num>, T, U, V, W) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X), F, false>
where F: Fn(T, U, V, W, X) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X), F, true>
where F: Fn(&mut CallContext<'_, Num>, T, U, V, W, X) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X, Y> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X, Y), F, false>
where F: Fn(T, U, V, W, X, Y) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Y: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X, Y> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X, Y), F, true>
where F: Fn(&mut CallContext<'_, Num>, T, U, V, W, X, Y) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Y: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X, Y, Z> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X, Y, Z), F, false>
where F: Fn(T, U, V, W, X, Y, Z) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Y: TryFromValue<Num>, Z: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X, Y, Z> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X, Y, Z), F, true>
where F: Fn(&mut CallContext<'_, Num>, T, U, V, W, X, Y, Z) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Y: TryFromValue<Num>, Z: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X, Y, Z, A> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X, Y, Z, A), F, false>
where F: Fn(T, U, V, W, X, Y, Z, A) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Y: TryFromValue<Num>, Z: TryFromValue<Num>, A: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X, Y, Z, A> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X, Y, Z, A), F, true>
where F: Fn(&mut CallContext<'_, Num>, T, U, V, W, X, Y, Z, A) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Y: TryFromValue<Num>, Z: TryFromValue<Num>, A: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X, Y, Z, A, B> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X, Y, Z, A, B), F, false>
where F: Fn(T, U, V, W, X, Y, Z, A, B) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Y: TryFromValue<Num>, Z: TryFromValue<Num>, A: TryFromValue<Num>, B: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X, Y, Z, A, B> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X, Y, Z, A, B), F, true>
where F: Fn(&mut CallContext<'_, Num>, T, U, V, W, X, Y, Z, A, B) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Y: TryFromValue<Num>, Z: TryFromValue<Num>, A: TryFromValue<Num>, B: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X, Y, Z, A, B, C> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X, Y, Z, A, B, C), F, false>
where F: Fn(T, U, V, W, X, Y, Z, A, B, C) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Y: TryFromValue<Num>, Z: TryFromValue<Num>, A: TryFromValue<Num>, B: TryFromValue<Num>, C: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<Num, F, Ret, T, U, V, W, X, Y, Z, A, B, C> NativeFn<Num> for FnWrapper<(Ret, T, U, V, W, X, Y, Z, A, B, C), F, true>
where F: Fn(&mut CallContext<'_, Num>, T, U, V, W, X, Y, Z, A, B, C) -> Ret, T: TryFromValue<Num>, U: TryFromValue<Num>, V: TryFromValue<Num>, W: TryFromValue<Num>, X: TryFromValue<Num>, Y: TryFromValue<Num>, Z: TryFromValue<Num>, A: TryFromValue<Num>, B: TryFromValue<Num>, C: TryFromValue<Num>, Ret: IntoEvalResult<Num>,

source§

impl<T> NativeFn<T> for Compare

source§

impl<T> NativeFn<T> for Array
where T: 'static + Clone + Zero + One,

source§

impl<T> NativeFn<T> for Assert

source§

impl<T> NativeFn<T> for If

source§

impl<T> NativeFn<T> for Push

source§

impl<T, F> NativeFn<T> for F
where F: 'static + Fn(Vec<SpannedValue<T>>, &mut CallContext<'_, T>) -> EvalResult<T>,

source§

impl<T: 'static + Clone> NativeFn<T> for AssertFails

source§

impl<T: 'static + Clone> NativeFn<T> for Filter

source§

impl<T: 'static + Clone> NativeFn<T> for Fold

source§

impl<T: 'static + Clone> NativeFn<T> for Map

source§

impl<T: 'static + Clone> NativeFn<T> for While

source§

impl<T: Clone + 'static> NativeFn<T> for All

source§

impl<T: Clone + 'static> NativeFn<T> for Any

source§

impl<T: Clone + 'static> NativeFn<T> for Defer

source§

impl<T: Clone + Display> NativeFn<T> for AssertClose<T>

source§

impl<T: Clone> NativeFn<T> for Merge

source§

impl<T: Display> NativeFn<T> for AssertEq

source§

impl<T: Display> NativeFn<T> for Dbg

source§

impl<T: FromPrimitive> NativeFn<T> for Len