[][src]Macro genco::push

macro_rules! push {
    ($dest:expr, |$t:ident| $code:block) => { ... };
    ($dest:expr, $($x:expr),*) => { ... };
    ($dest:expr, $($x:expr,)*) => { ... };
}
👎 Deprecated since 0.5.0:

Use the quote! procedural macro instead.

Helper macro to reduce boilerplate needed with pushed token expressions.

All arguments being pushed are cloned, which should be cheap for reference types.

Examples

use genco::{Tokens, Java, ItemStr};

let mut toks = Tokens::<Java>::new();
// id being cloned.
let id = ItemStr::Static("hello");

push!(toks, "foo ", id);
push!(toks, "bar ", id);

assert_eq!(
    vec![
        "foo hello",
        "bar hello",
        ""
    ],
    toks.to_file_vec().unwrap()
);

Pushing as a block:

use genco::{Tokens, Java, ItemStr};

let mut toks = Tokens::<Java>::new();
// id being cloned.
let id = ItemStr::from("hello");

push!(toks, |t| {
  push!(t, "foo ", id);
  push!(t, "bar ", id);
});

assert_eq!(
    vec![
        "foo hello",
        "bar hello",
        ""
    ],
    toks.to_file_vec().unwrap()
);