[][src]Macro pmutil::smart_quote

macro_rules! smart_quote {
    (
        Vars{ $($vars:tt)* },
        {
            $(
                $tokens:tt
            )*
        }
    ) => { ... };
    (
        Vars{ $($vars:tt)* },
        (
            $(
                $tokens:tt
            )*
        )
    ) => { ... };
}

ide-friendly quasi quotting.

Syntax

Vars

Syntax is simillar to field initialization syntax.

This example is not tested
Vars {
  a,
  b: expr_b,
  c: fn_c(),
  d,
}
 // is equivalent to
Vars {
  a: a,
  b: expr_b,
  c: fn_c(),
  d: d,
}

Note that Vars{} is required even if there's no variable.

Tokens

As parsers for syntax highligters implement error recovery, tokens are wrapped in block or paren like { tokens.. }/ ( tokens.. ).

Example

This example is not tested
 smart_quote!(Vars{
     OrigTrait: tr.ident,
     SpecializerTrait: tr.ident.new_ident_with(|tr| format!("{}Specializer", tr)),
 }, {
     impl<T> OrigTrait for T where T: SpecializerTrait {
     }
 })

Example (no variable)

This example is not tested
 smart_quote!(Vars{}, {
     yield ();
 })