[][src]Macro rune_macros::quote

quote!() { /* proc-macro */ }

Macro helper function for quoting the token stream as macro output.

Is capable of quoting everything in Rune, except for the following:

  • Pound signs (#), which can be inserted by using #(ast::Pound) instead. These are used in object literal, and are a limitiation in the quote macro because we use the pound sign to delimit variables.
  • Labels, which must be created using [crate::MacroContext::label].
  • Template strings, which must be created using [crate::MacroContext::template_string].

Panics

Calling this macro will panic if called outside of a macro context. A macro context can be setup using with_context.

use rune::macros::{with_context, MacroContext};
let ctx = MacroContext::empty();

with_context(ctx, || {
    rune::quote!(hello self);
});

Interpolating values

Values are interpolated with #value, or #(value + 1) for expressions.

Iterators

Anything that can be used as an iterator can be iterated over with #(iter)*. A token can also be used to join inbetween each iteration, like #(iter),*.