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

ide-friendly quasi quotting.

Syntax

Vars

Syntax is simillar to field initialization syntax.

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

 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)

 smart_quote!(Vars{}, {
     yield ();
 })