::function_name
Function attribute #[named]
that generates a function_name!
macro
in the scope of the function's body.
The generated function_name!()
is a macro that expands to
the name of the annotated function, as a string literal.
```rust use ::function_name::named;
fn mysuperduperfunction () { asserteq!( functionname!(), "mysuperduperfunction", ); } ```
Since the generated function_name!
expands to a string literal,
it can be used with other macros such as concat!
:
```rust
macrorules! functionpath {() => (concat!( modulepath!(), "::", functionname!() ))}
pub mod foo { pub mod bar { #[named] pub fn baz () { asserteq!( functionpath!(), [ env!("CARGOPKGNAME"), "foo", "bar", "baz", ].join("::"), ); } } } ```