tokenstream2-tmpl
This crate is meant to be a complement to quote. Where as quote does quasi-quote interpolations at compile-time, this crate does them at run-time. This is handy for macros receiving templates from client code with markers to be replaced when the macro is run.
Examples
use TokenStream;
use tokenstream2- interpolate;
use ToTokens;
use HashMap;
use ;
let input: TokenStream = parse_str?;
let expected: TokenStream = parse_str?;
let mut replacements: = new;
let ident = ?;
replacements.insert;
let output = interpolate;
assert_eq!;
Here input
might be some input to a macro that functions as a template. quote would have tried to expand NAME
at the macro's compile-time. tokenstream2-tmpl will expand it at the macro's run-time.
extern crate proc_macro;
use TokenStream;
use HashMap;
use ;
use tokenstream2-;
use ToTokens;
/// Create a token for macro using [syn](syn)
/// Type that holds a key and the value it maps to.
/// An acceptable stream will have the following form:
/// ```text
/// key => value
/// ```
/// Make KeyValue parsable from a token stream
/// Make KeyValue interpolatible
/// Macro to take a list of key-values with a template to expand each key-value
License: MIT