stringify-attr 1.0.0

Attribute macros for stringifying
Documentation
  • Coverage
  • 85.71%
    6 out of 7 items documented0 out of 6 items with examples
  • Size
  • Source code size: 7.43 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 271.18 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Popog/stringify-attr
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Popog

stringify-attr

Crate Version Documentation Zlib

Attribute macros for stringifying. Probably only useful in unit tests and debugging, but who knows.

Usage

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.