Crates.io | stringify-attr |
lib.rs | stringify-attr |
version | 1.0.0 |
source | src |
created_at | 2020-03-21 01:26:20.889128 |
updated_at | 2020-03-21 01:26:20.889128 |
description | Attribute macros for stringifying |
homepage | https://github.com/Popog/stringify-attr |
repository | https://github.com/Popog/stringify-attr |
max_upload_size | |
id | 220844 |
size | 7,963 |
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:
use stringify_attr::stringify_attr;
assert_eq!(
{
#[stringify_attr(foo)] struct Foo;
result!()
},
"foo"
);
Just items:
use stringify_attr::stringify_item;
assert_eq!(
{
#[stringify_item(foo)] struct Foo;
result!()
},
"struct Foo;"
);
Or the whole thing:
use stringify_attr::stringify_all;
assert_eq!(
{
#[stringify_all(foo)] struct Foo;
result!()
},
"#[stringify_all(foo)] struct Foo;"
);
Since attribute macros cannot differential being invoked with different delimeters, different attributes are provided:
use stringify_attr::stringify_braces as stringify_all;
assert_eq!(
{
#[stringify_all{foo}] struct Foo;
result!()
},
"#[stringify_all{foo}] struct Foo;"
);
Note that these attributes still produce the text "stringify_all"
in the output.