Releases: dtolnay/quote
Releases · dtolnay/quote
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
- Extend the repetition syntax and align it more closely with the style of
macro_rules!
repetitions. This is a breaking change and code that used to look like#(var)*
needs to be updated to#(#var)*
.
Some examples of the new repetition style:
let keys = vec!["a", "b"];
let values = vec![true, false];
// "a": true, "b": false
quote! {
#(#keys: #values),*
}
let nested = vec![
vec!['a', 'b', 'c'],
vec!['x', 'y', 'z'],
];
// 'a' 'b' 'c', 'x' 'y' 'z'
quote! {
#(
#(#nested)*
),*
}
In general it should feel just like macro_rules!
repetitions except with #
instead of $
. The remaining limitations are:
- Cannot mix repeating and non-repeating tokens at the same level. If
#a
is repeating (like a Vec) and#b
is not, thenquote! { #(#a #b)* }
will not work. Ideally it would insert the same#b
for each#a
the waymacro_rules!
does but I have not figured this out yet. For now you can explicitly repeatb
usingstd::iter::repeat
. - Cannot repeat the same tokens more than once at the same repetition level.
quote! { #a #a }
continues to work as before but I have not figured out a way to supportquote! { #(#a #a)* }
.
0.3.0-rc2
0.3.0-rc1
0.2.3
- Add helpers
append_all
andappend_terminated
to simplify ToTokens implementations.