pub trait ToLisp<const N: usize> {
// Required method
fn to_lisp(&self, lisp: &Lisp<N>) -> Result<ArenaIndex, ArenaError>;
}Expand description
Trait for converting Rust types to Lisp values.
Implement this trait for any type you want to return to Lisp code.
§Example
use grift_eval::{ToLisp, Lisp, ArenaIndex, ArenaResult};
// isize is already implemented
fn example<const N: usize>(lisp: &Lisp<N>, value: isize) -> ArenaResult<ArenaIndex> {
value.to_lisp(lisp)
}Required Methods§
Sourcefn to_lisp(&self, lisp: &Lisp<N>) -> Result<ArenaIndex, ArenaError>
fn to_lisp(&self, lisp: &Lisp<N>) -> Result<ArenaIndex, ArenaError>
Convert this Rust value to a Lisp value, allocating in the arena.
Returns the ArenaIndex of the newly allocated value.