1use super::{2 arglike::{ArgLike, OptionalContext},3 FuncVal,4};5use crate::{error::Result, typed::Typed};67pub trait NativeDesc {8 type Value;9 fn into_native(val: FuncVal) -> Self::Value;10}11macro_rules! impl_native_desc {12 ($($gen:ident)*) => {13 impl<$($gen,)* O> NativeDesc for (($($gen,)*), O)14 where15 $($gen: ArgLike + OptionalContext,)*16 O: Typed,17 {18 type Value = Box<dyn Fn($($gen,)*) -> Result<O>>;1920 #[allow(non_snake_case)]21 fn into_native(val: FuncVal) -> Self::Value {22 Box::new(move |$($gen),*| {23 let val = val.evaluate_simple(24 &($($gen,)*),25 )?;26 O::from_untyped(val)27 })28 }29 }30 };31 ($($cur:ident)* @ $c:ident $($rest:ident)*) => {32 impl_native_desc!($($cur)*);33 impl_native_desc!($($cur)* $c @ $($rest)*);34 };35 ($($cur:ident)* @) => {36 impl_native_desc!($($cur)*);37 }38}3940impl_native_desc! {41 @ A B C D E F G H I J K L42}