Skip to main content

FromLisp

Trait FromLisp 

Source
pub trait FromLisp<const N: usize>: Sized {
    // Required method
    fn from_lisp(lisp: &Lisp<N>, idx: ArenaIndex) -> Result<Self, ArenaError>;
}
Expand description

Trait for converting Lisp values to Rust types.

Implement this trait for any type you want to extract from Lisp arguments.

§Example

use grift_eval::{FromLisp, Lisp, ArenaIndex, ArenaResult, Value};

// isize is already implemented
fn example<const N: usize>(lisp: &Lisp<N>, idx: ArenaIndex) -> ArenaResult<isize> {
    isize::from_lisp(lisp, idx)
}

Required Methods§

Source

fn from_lisp(lisp: &Lisp<N>, idx: ArenaIndex) -> Result<Self, ArenaError>

Convert a Lisp value at the given index to this Rust type.

Returns an error if the conversion fails (e.g., type mismatch).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<const N: usize> FromLisp<N> for bool

Source§

impl<const N: usize> FromLisp<N> for char

Source§

impl<const N: usize> FromLisp<N> for isize

Source§

impl<const N: usize> FromLisp<N> for ()

Implementors§

Source§

impl<const N: usize> FromLisp<N> for ArenaIndex

ArenaIndex can be passed through directly (for when you want raw Lisp values)