quote

Macro quote 

Source
quote!() { /* proc-macro */ }
Expand description

Like unquote!, but starts out in quoted mode, meaning that tokens will be pasted verbatim.

Template tags [< ... >] can be used to construct dynamic elements.

See this crate’s root for a basic language documentation.

§Example

use metamatch::quote;

quote! {
    enum ErrorCode {
        [<for err_id in 0..=42>]
            [<ident("E" + str(err_id))>](String),
        [</for>]
    }
};
let err = ErrorCode::E42("oh noes!".to_owned());

§Supported template tags

  • [<for ..>] [</for>]
  • [<while ..>] [</while>]
  • [<while let ...>] [</while>]
  • [<loop>] [</loop>]
  • [<if ..>] [<else if ..>] [<else>] [</if>]
  • [<fn .. (..)>] [</fn>]
  • [<let .. = ..>];
  • [< ("arbitrary expressions") >]

§Special tags

  • [<unquote>][</unquote>]: Evaluate expressions.
  • [<raw>]..[</raw>]: Paste raw Rust without identifier replacements.