Skip to content

Instantly share code, notes, and snippets.

To From Method
string of code literal code std::stringify!{}
string of code syntax tree !quote(#syntax_tree).to_string()
string of code TokenStream .to_string()
string of syntax literal code format!("{:?}",parse2::<SynType>(quote! {...}).expect(...)
string of syntax syntax tree format!("{:?}"),…), format!("{:#?}"),…)
string of tokens literal code format!("{:?}",quote! {...})
string of tokens TokenStream format!("{:?}"),…), format!("{:#?}"),…)
syn::Error TokenStream .to_compile_error() [see Rule #7]
syntax tree literal code parse_quote!(…)