commit | 90c5061a54c2bbe72ca2446369abfcd2b9f2790b | [log] [tgz] |
---|---|---|
author | Michael Layzell <michael@thelayzells.com> | Sun Oct 09 17:21:38 2016 -0400 |
committer | Michael Layzell <michael@thelayzells.com> | Sun Oct 09 17:21:38 2016 -0400 |
tree | b4c0a661bb554d2e121157f67ac00c7139693f3b | |
parent | 53a3d38c649fdbd8a80d040eb0651ca4a038f8cb [diff] |
Add support for passing no tokens to quote!()
Quasi-quoting without a Syntex dependency, intended for use with Macros 1.1.
[dependencies] quote = "0.3"
#[macro_use] extern crate quote;
Interpolation is done with #var
:
let tokens = quote! { struct SerializeWith #generics #where_clause { value: &'a #field_ty, phantom: ::std::marker::PhantomData<#item_ty>, } impl #generics serde::Serialize for SerializeWith #generics #where_clause { fn serialize<S>(&self, s: &mut S) -> Result<(), S::Error> where S: serde::Serializer { #path(self.value, s) } } SerializeWith { value: #value, phantom: ::std::marker::PhantomData::<#item_ty>, } };
Repetition is done using #(...)*
or #(...),*
very similar to macro_rules!
:
#(#var)*
- no separators#(#var),*
- the character before the asterisk is used as a separator#( struct #var; )*
- the repetition can contain other thingsLicensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.