Skip to main content

macro_data_transfer

Macro macro_data_transfer 

Source
macro_rules! macro_data_transfer {
    (
        @normal,
        $target:path,
        ($accu:tt, $($accu_tail:tt,)*),
        (($($arg:tt)*) $($arg_tail:tt)*),
    ) => { ... };
    (
        @normal,
        $target:path,
        (($($accu:tt)*), ($($accu_prev:tt)*), $($accu_tail:tt,)*),
        (@close_param $($arg_tail:tt)*),
    ) => { ... };
    (
        @normal,
        $target:path,
        ($accu:tt, $($accu_tail:tt,)*),
        ([$($arg:tt)*] $($arg_tail:tt)*),
    ) => { ... };
    (
        @normal,
        $target:path,
        (($($accu:tt)*), ($($accu_prev:tt)*), $($accu_tail:tt,)*),
        (@close_bracket $($arg_tail:tt)*),
    ) => { ... };
    (
        @normal,
        $target:path,
        ($accu:tt, $($accu_tail:tt,)*),
        ({$($arg:tt)*} $($arg_tail:tt)*),
    ) => { ... };
    (
        @normal,
        $target:path,
        (($($accu:tt)*), ($($accu_prev:tt)*), $($accu_tail:tt,)*),
        (@close_braces $($arg_tail:tt)*),
    ) => { ... };
    (
        @normal,
        $target:path,
        $accu:tt,
        (@load ($data:path) $($arg_tail:tt)*),
    ) => { ... };
    (
        (
            @ret,
            $target:path,
            (($($accu:tt)*), $($accu_tail:tt,)*),
            $arg_tail:tt,
        ),
        ($($value:tt)*),
    ) => { ... };
    (
        @normal,
        $target:path,
        (($($accu:tt)*), $($accu_tail:tt,)*),
        ($arg:tt $($arg_tail:tt)*),
    ) => { ... };
    (
        @normal,
        $target:path,
        ($accu:tt,),
        (),
    ) => { ... };
    (
        $target:path,
        $arg:tt,
    ) => { ... };
}
Expand description

This macro is used by other proc macros to transfer data.

It must be public to use it, but please don’t call it directly.

Internal

  • The entry syntax is macro_data_transfer!(<target-macro-path>, (<tokens>));
  • Keep the result in accu, which is a list of tokentrees
    • Nested groups create a new tokentree to the left
    • Closing the group combines two tokentrees
  • Use @load(<path>) to call a macro and use the returned tokens
    • Other tokens are returned as is