pub fn macro_<N, M, A, O>(&mut self, name: N, f: M) -> Result<(), ContextError>
    where
        M: 'static + Send + Sync + Copy + Fn(&A) -> Result<O, crate::Error>,
        A: any::Any,
        O: any::Any,
        N: IntoIterator,
        N::Item: IntoComponent,
    {
        let name = Item::with_item(name);

        if self.macros.contains_key(&name) {
            return Err(ContextError::ConflictingFunctionName { name });
        }

        let handler: Arc<Macro> = Arc::new(move |a| {
            let a = match a.downcast_ref::<A>() {
                Some(a) => a,
                None => {
                    return Err(crate::Error::msg(format!(
                        "expected argument #1 `{}`",
                        std::any::type_name::<A>()
                    )));
                }
            };

            let output = f(a)?;
            Ok(Box::new(output))
        });

        self.macros.insert(name, ModuleMacro { handler });
        Ok(())
    }
/// Register a native macro handler.
Register a native macro handler.
Register a native macro handler .
pub fn macro_<N, M, A, O>(&mut self, name: N, f: M) -> Result<(), ContextError>
    where
        M: 'static + Send + Sync + Copy + Fn(&A) -> Result<O, crate::Error>,
        A: any::Any,
        O: any::Any,
        N: IntoIterator,
        N::Item: IntoComponent,
    {
        let name = Item::with_item(name);
        if self.macros.contains_key(&name) {
            return Err(ContextError::ConflictingFunctionName { name });
        }
        let handler: Arc<Macro> = Arc::new(move |a| {
            let a = match a.downcast_ref::<A>() {
                Some(a) => a,
                None => {
                    return Err(crate::Error::msg(format!(
                        "expected argument #1 `{}`",
                        std::any::type_name::<A>()
                    )));
                }
            };
            let output = f(a)?;
            Ok(Box::new(output))
        });
        self.macros.insert(name, ModuleMacro { handler });
        Ok(())
    }
pub fn macro_ < N , M , A , O > ( & mut self , name : N , f : M ) -> Result < ( ) , ContextError > where M : ' static + Send + Sync + Copy + Fn ( & A ) -> Result < O , crate :: Error > , A : any :: Any , O : any :: Any , N : IntoIterator , N :: Item : IntoComponent , { let name = Item :: with_item ( name ) ; if self . macros . contains_key ( & name ) { return Err ( ContextError :: ConflictingFunctionName { name } ) ; } let handler : Arc < Macro > = Arc :: new ( move | a | { let a = match a . downcast_ref :: < A > ( ) { Some ( a ) => a , None => { return Err ( crate :: Error :: msg ( format ! ( " " std any type_name A ( ) ) ) ) ; } } ; let output = f ( a ) ? ; Ok ( Box :: new ( output ) ) } ) ; self . macros . insert ( name , ModuleMacro { handler } ) ; Ok ( ( ) ) }
Register a native macro handler.
Register a native macro handler .
&mut self
name
N
f
M
&mut self
name
N
f
M