use crate::prelude::*; use std::fmt::{Debug, Display}; pub struct Function { pub name: Rc, pub arity: usize, pub variadic: bool, pub fun: InnerFunction } #[derive(Clone)] pub enum InnerFunction { Compiled(Rc), Native(Rc) -> Result>), } impl Debug for Function { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { use InnerFunction as F; match self.fun { F::Compiled(_) => { write!(f, "[Function {}]", self.name) }, F::Native(_) => { write!(f, "[Builtin {}]", self.name) } } } } impl Display for Function { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { use InnerFunction as F; match self.fun { F::Compiled(_) => { write!(f, "[Function {}]", self.name) }, F::Native(_) => { write!(f, "[Builtin {}]", self.name) } } } }