Skip to main content

NativeProcedure

Struct NativeProcedure 

Source
pub struct NativeProcedure { /* private fields */ }
Expand description

A native function.

Implementations§

Source§

impl NativeProcedure

Source

pub fn new( name: &'static str, func: impl Fn(&<TinyLang as Interpreter>::Env, &[<TinyLang as Interpreter>::Expr]) -> Result<<TinyLang as Interpreter>::Value, <TinyLang as Interpreter>::Error> + 'static, ) -> Self

Create a NativeProcedure.

Source

pub fn register(self, env: &<TinyLang as Interpreter>::Env)

Register the function to an environment.

Trait Implementations§

Source§

impl AbstractValue<TinyLang> for NativeProcedure

Source§

fn apply( &self, env: &<TinyLang as Interpreter>::Env, args: &[<TinyLang as Interpreter>::Expr], ) -> Result<<TinyLang as Interpreter>::Value, <TinyLang as Interpreter>::Error>

Call a function. Read more
Source§

impl Debug for NativeProcedure

Source§

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

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

impl Display for NativeProcedure

Source§

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

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

impl<R, A> From<(&'static str, fn(&A) -> R)> for NativeProcedure

Source§

fn from(value: (&'static str, fn(&A) -> R)) -> Self

Converts to this type from the input type.
Source§

impl<R, A> From<(&'static str, fn(&A) -> Result<R, <TinyLang as Interpreter>::Error>)> for NativeProcedure

Source§

fn from( value: (&'static str, fn(&A) -> Result<R, <TinyLang as Interpreter>::Error>), ) -> Self

Converts to this type from the input type.
Source§

impl<R, A, B> From<(&'static str, fn(&A, &B) -> R)> for NativeProcedure

Source§

fn from(value: (&'static str, fn(&A, &B) -> R)) -> Self

Converts to this type from the input type.
Source§

impl<R, A, B> From<(&'static str, fn(&A, &B) -> Result<R, <TinyLang as Interpreter>::Error>)> for NativeProcedure

Source§

fn from( value: (&'static str, fn(&A, &B) -> Result<R, <TinyLang as Interpreter>::Error>), ) -> Self

Converts to this type from the input type.
Source§

impl<R, A, B, C> From<(&'static str, fn(&A, &B, &C) -> R)> for NativeProcedure

Source§

fn from(value: (&'static str, fn(&A, &B, &C) -> R)) -> Self

Converts to this type from the input type.
Source§

impl<R, A, B, C> From<(&'static str, fn(&A, &B, &C) -> Result<R, <TinyLang as Interpreter>::Error>)> for NativeProcedure

Source§

fn from( value: (&'static str, fn(&A, &B, &C) -> Result<R, <TinyLang as Interpreter>::Error>), ) -> Self

Converts to this type from the input type.
Source§

impl<R, A, B, C, D> From<(&'static str, fn(&A, &B, &C, &D) -> R)> for NativeProcedure

Source§

fn from(value: (&'static str, fn(&A, &B, &C, &D) -> R)) -> Self

Converts to this type from the input type.
Source§

impl<R, A, B, C, D> From<(&'static str, fn(&A, &B, &C, &D) -> Result<R, <TinyLang as Interpreter>::Error>)> for NativeProcedure

Source§

fn from( value: (&'static str, fn(&A, &B, &C, &D) -> Result<R, <TinyLang as Interpreter>::Error>), ) -> Self

Converts to this type from the input type.
Source§

impl<R, A, B, C, D, E> From<(&'static str, fn(&A, &B, &C, &D, &E) -> R)> for NativeProcedure

Source§

fn from(value: (&'static str, fn(&A, &B, &C, &D, &E) -> R)) -> Self

Converts to this type from the input type.
Source§

impl<R, A, B, C, D, E> From<(&'static str, fn(&A, &B, &C, &D, &E) -> Result<R, <TinyLang as Interpreter>::Error>)> for NativeProcedure

Source§

fn from( value: (&'static str, fn(&A, &B, &C, &D, &E) -> Result<R, <TinyLang as Interpreter>::Error>), ) -> Self

Converts to this type from the input type.
Source§

impl Trace for NativeProcedure

Source§

fn trace(&self, tracer: &mut Tracer<'_>)

Define how to visit values referred by this value. Read more
Source§

fn is_type_tracked() -> bool

Whether this type should be tracked by the collector. Read more
Source§

fn as_any(&self) -> Option<&dyn Any>

Provide downcast support. Read more

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.