Struct knightrs::function::Function [−][src]
pub struct Function { /* fields omitted */ }
The type that represents functions themselves (eg PROMPT
, +
, =
, etc.) within Knight.
Note that Function
s cannot be created directly—you must fetch
them. New functions can be
register
ed if so desired.
Implementations
impl Function
[src]
impl Function
[src]#[must_use]pub fn func(
&self
) -> fn(_: &[Value], _: &mut Environment<'_, '_, '_>) -> Result<Value, Error>
[src]
#[must_use]
pub fn func(&self
) -> fn(_: &[Value], _: &mut Environment<'_, '_, '_>) -> Result<Value, Error>
Gets the function pointer associated with self
.
pub fn run(
&self,
args: &[Value],
env: &mut Environment<'_, '_, '_>
) -> Result<Value, Error>
[src]
&self,
args: &[Value],
env: &mut Environment<'_, '_, '_>
) -> Result<Value, Error>
Executes this function with the given arguments
#[must_use]pub fn arity(&self) -> usize
[src]
#[must_use]
pub fn arity(&self) -> usizeGets the arity of this function.
#[must_use]pub fn name(&self) -> char
[src]
#[must_use]
pub fn name(&self) -> charGets the name of the function.
#[must_use = "fetching a function does nothing by itself"]pub fn fetch(name: char) -> Option<Self>
[src]
#[must_use = "fetching a function does nothing by itself"]
pub fn fetch(name: char) -> Option<Self>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]
name: char,
arity: usize,
func: fn(_: &[Value], _: &mut Environment<'_, '_, '_>) -> Result<Value, Error>
)
Registers a new function with the given name, discarding any previous value associated with it.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Function
impl RefUnwindSafe for Function
impl UnwindSafe for Function
impl UnwindSafe for Function