1use super::{2 arglike::{ArgLike, OptionalContext},3 FuncVal,4};5use crate::{typed::Typed, Result};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 false,26 )?;27 O::from_untyped(val)28 })29 }30 }31 };32 ($($cur:ident)* @ $c:ident $($rest:ident)*) => {33 impl_native_desc!($($cur)*);34 impl_native_desc!($($cur)* $c @ $($rest)*);35 };36 ($($cur:ident)* @) => {37 impl_native_desc!($($cur)*);38 }39}4041impl_native_desc! {42 @ A B C D E F G H I J K L43}