Expand description

This module contains a trait ToFunctionInterface which allows to write nice function interfaces by using much less boilerplate to define functions.

Examples:

use debris_core::{objects::{ObjInt, FunctionContext}, ObjectRef, error::LangResult};

/// The most general form of a function
fn foo(ctx: &mut FunctionContext, objects: &[ObjectRef]) -> LangResult<ObjectRef> {
    // [...]
}

/// Return types can be anything that can be converted into a LangResult<ObjectRef>, so this is also valid
fn bar(ctx: &mut FunctionContext, objects: &[ObjectRef]) -> ObjectRef {
    // [...]
}

/// Instead of taking an arbitrary amount of any object, it is possible to specify which objects are required
fn square(_ctx: &mut FunctionContext, value: &ObjInt) -> ObjInt {
    // [...]
}

/// Since integers can be converted into `ObjStaticInt`, this is also possible
/// Note that `ctx` can be omitted if it is not needed
fn square_static(value: &ObjStaticInt) -> i32 {
    value.value * value.value
}

Macros

Structs

Traits

Functions

Type Aliases