Macro tt_call::tt_return[][src]

macro_rules! tt_return {
    {
        $caller:tt
        $(
            $output:ident = [{ $($tokens:tt)* }]
        )*
    } => { ... };
}
Expand description

Return zero or more output values to the caller macro.

Input

The tt_return! invocation should be given a $caller to return to and a sequence of zero or more named return values.

  • $(
      arbitrary key = [{ arbitrary tokens }]
    )*

Example

use tt_call::{tt_call, tt_return};

macro_rules! is_lowercase_self {
    // Input token is `self`.
    {
        $caller:tt
        input = [{ self }]
    } => {
        tt_return! {
            $caller
            is = [{ true }]
        }
    };

    // Input token is anything other than `self`.
    {
        $caller:tt
        input = [{ $other:tt }]
    } => {
        tt_return! {
            $caller
            is = [{ false }]
        }
    };
}

fn main() {
    let is = tt_call! {
        macro = [{ is_lowercase_self }]
        input = [{ self }]
    };
    println!("{}", is);
}