Attribute macros for stringifying. Probably only useful in unit tests and debugging, but who knows.
Basically these macros allow you to stringify using attribute macros instead of the normal stringify!
. Since attribute macros must produce an item. Each macro produces a result!
macro which expands to the desired string.
You can stringify just attributes: ```rust use stringifyattr::stringifyattr;
asserteq!(
{
#[stringifyattr(foo)] struct Foo;
result!()
},
"foo"
);
Just items:
rust
use stringifyattr::stringifyitem;
asserteq!(
{
#[stringifyitem(foo)] struct Foo;
result!()
},
"struct Foo;"
);
Or the whole thing:
rust
use stringifyattr::stringifyall;
asserteq!( { #[stringifyall(foo)] struct Foo; result!() }, "#[stringify_all(foo)] struct Foo;" ); ```
Since attribute macros cannot differential being invoked with different delimeters, different attributes are provided: ```rust use stringifyattr::stringifybraces as stringify_all;
asserteq!( { #[stringifyall{foo}] struct Foo; result!() }, "#[stringify_all{foo}] struct Foo;" ); ```
Note that these attributes still produce the text "stringify_all"
in the output.