macro_rules! quote {
($($tokens:tt)*) => { ... };
}Expand description
unsynn provides its own quote!{} macro that translates tokens into a TokenStream while
interpolating variables prefixed with a Pound sign (#). This is similar to what the quote macro from
the quote crate does but not as powerful. There is no #(...) repetition (yet).
Instead we provide #{...} blocks which must return a IntoIterator whose items
implement ToTokens. When blocks returns a single value just wrap this in Some()
because Option implements the necessary IntoIterator.
ยงExample
let ast = <Cons<ConstInteger<1>, Plus, ConstInteger<2>>>::default();
let quoted = quote! { let a = #ast;};
assert_tokens_eq!(quoted, "let a = 1+2;");
// or using #{...} blocks
let quoted = quote! {
let a = #{Some(<Cons<ConstInteger<1>, Plus, ConstInteger<2>>>::default())};
};
assert_tokens_eq!(quoted, "let a = 1+2;");