metamatch!
A zero dependency proc-macro for practical metaprogramming.
Macro expressions using familiar Rust syntax, evaluated by a tiny interpreter.
Two specialized entrypoints for common usecases, two generalized versions for maximum flexibility.
#[replicate]
Generate repetitive syntax like trait impls without giving up on
rustfmt or rust-analyzer.
use replicate;
;
assert!;
metamatch!
The original motivation and namesake of this crate.
Match arms for differently typed variants cannot be combined, even if the are
syntactically identical. This macro lets you stamp out the neccessary
copies using (#[expand]).
Just like #[replicate], this macro is fully compatible rustfmt
and rust-analyzer. It will be correctly formatted like a regular
match expression, and is targettable even by auto refactorings
that affect the #[expand], like changing the name of an enum variant.
use metamatch;
unquote!
Evaluate arbitrary expressions.
use unquote;
const ARRAY: = unquote! ;
assert_eq!;
quote!
Like unquote!, but starts out in quoted mode.
It supports [< ... >] styled template tags for readable templating
within large blocks of rust code with few dynamic parts.
use quote;
quote! ;
let err = E42;
You can switch between quoted and unquoted mode from within any macro using
the [<quote>] and [<unquote>] template tags.
The quote!(..) used earlier is a covenience alias for [<quote>]..[</quote>]
License
MIT or Apache Version 2.0, at your option.