Type Definition rad::MacroType

source · []
pub type MacroType = fn(_: &str, _: bool, _: &mut Processor<'_>) -> RadResult<Option<String>>;
Expand description

Type signature of basic macros

This is in order of args, greediness, processor’s mutable reference

Example

fn demo(args: &str, greedy: bool, processor: &mut Processor) -> RadResult<Option<String>> {
    let mut medium = String::new();
    // Some logics go here
    if this_macro_prints_something {
        Ok(Some(medium))
    } else {
        // If return "None", then single newline will be removed
        Ok(None)
    }
}

// ... While building a processor ...
processor.add_basic_rules(vec![("test", test as MacroType)]);