Struct knightrs::Function[][src]

pub struct Function { /* fields omitted */ }

The type that represents functions themselves (eg PROMPT, +, =, etc.) within Knight.

Note that Functions cannot be created directly—you must fetch them. New functions can be registered if so desired.

Implementations

impl Function[src]

#[must_use]
pub fn func(
    &self
) -> fn(_: &[Value], _: &mut Environment<'_, '_, '_>) -> Result<Value, Error>
[src]

Gets the function pointer associated with self.

pub fn run(
    &self,
    args: &[Value],
    env: &mut Environment<'_, '_, '_>
) -> Result<Value, Error>
[src]

Executes this function with the given arguments

#[must_use]
pub fn arity(&self) -> usize
[src]

Gets the arity of this function.

#[must_use]
pub fn name(&self) -> char
[src]

Gets the name of the function.

#[must_use = "fetching a function does nothing by itself"]
pub fn fetch(name: char) -> Option<Self>
[src]

Gets the function associate dwith the given name, returning None if no such function exists.

pub fn register(
    name: char,
    arity: usize,
    func: fn(_: &[Value], _: &mut Environment<'_, '_, '_>) -> Result<Value, Error>
)
[src]

Registers a new function with the given name, discarding any previous value associated with it.

Trait Implementations

impl Clone for Function[src]

impl Copy for Function[src]

impl Debug for Function[src]

impl Eq for Function[src]

impl Hash for Function[src]

impl PartialEq<Function> for Function[src]

fn eq(&self, rhs: &Self) -> bool[src]

Checks to see if two functions are identical.

Two functions are considered the same if their names, arities, and function pointers are identical.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,